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


Please Help Members By Posting Answers For Below Questions

How do you maintain database integrity where deletions from one table will automatically cause deletions in another table?

933


What are the advantages of using third-party tools?

720


What is the process of normalising?

752


What is 'write-ahead log' in sql server 2000 ?

794


What is database mirroring?

754






How does clustered and non clustered index work?

679


What are window functions in sql server?

686


How to link tables in sql server?

655


What is Sqlpaging in SqlServer 2005 ?

843


What is spatial and temporal data?

710


What is an sql server agent?

729


Where in ms sql server is ’100’ equal to ‘0’?

796


What are synonyms?

714


how many clustered indexes can be created on a table? : Sql server database administration

774


How to test odbc dsn connection settings?

705