Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Create Table with Parameters Using Stored Procedure

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2001-04-04 : 20:18:01
Allan writes "Hello,

I want to create a stored procedure that will create a table dynamically. When I execute this procedure, I'll provide a table name and (let's say) 2 field names:
exec CreateMyTable 'MyTableName', 'Field1', 'Field2'

The stored procedure I have now is:
CREATE PROC CreateMyTable @tableName varchar(20), @f1 varchar(20), @f2 varchar(20)
AS
....

When execute, this procedure would create a table with table name as @tableName & the 2 fields as @f1 & @f2.

Please help.

Thanks."
   

- Advertisement -