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 to connect to SQL Azure Database by using sqlcmd?
how many type of indexing in database?
How to download and install sql server 2005 books online?
How do I port a number to sql server?
What is the definition for sql server 2000?
Write an sql query for deleting duplicate rows?
Can we write a distributed query and get some data which is located on other server and oracle database?
Explain following error properties?
What is shared lock?
What is TDS(Tabular Data Stream) Gateway?
what is a transaction? : Sql server database administration
What does COMMIT command do?
Explain identity in sql server?
Does index speed up select statements?
What is dimension table? : sql server analysis services, ssas