i want to create procedure for create table in sql server
2005
for example
create procedure create_table
@table varchar(20)
as
create @table(
id int,
name char(20)
)
but it will get error
what is solution?
Answer Posted / patan
IF EXISTS (SELECT NAME FROM SYSOBJECTS WHERE NAME = 'PROCEDURENAME')
DROP PROCEDURE PROCEDURENAME
GO
CREATE PROCEDURE PROCEDURENAME
@TEST INT = 0
AS
BEGIN
--HERE CREATING TABLE
DECLARE @CREATE TABLE (ID INT ,NAME VARCHAR(20))
INSERT INTO @CREATE VALUES (1,'PATAN')
.
.
.
.
.
.
END
IN PROCEDURE WE CAN CREATE TABLE AND IT CAN USE THE OUR PROCEDURE @CREATE IS THE TABLE NAME
NOTE:WHILE RUNNING TIME WE CAN CREATE TABLE WITH THERE ALIES NAMES...
THANKS @ GOOD LUCK
Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
How do you maintain database integrity where deletions from one table will automatically cause deletions in another table?
What are the advantages of using third-party tools?
What is the process of normalising?
What is 'write-ahead log' in sql server 2000 ?
What is database mirroring?
How does clustered and non clustered index work?
What are window functions in sql server?
How to link tables in sql server?
What is Sqlpaging in SqlServer 2005 ?
What is spatial and temporal data?
What is an sql server agent?
Where in ms sql server is ’100’ equal to ‘0’?
What are synonyms?
how many clustered indexes can be created on a table? : Sql server database administration
How to test odbc dsn connection settings?