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.
| Author |
Topic |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2005-12-07 : 08:08:20
|
| nick writes "Hello there, well i need to create a simple stored procedure that it will create a new table in my database.I would like the name of the table to be passed as parameter to the procedure from my application.What i have tried untill now is the following:CREATE PROCEDURE SP_CREATE_TABLE @table_name varchar(100)ASdeclare @Name varchar(100)set @Name=@table_nameGOCREATE TABLE @Name(.....But it seems that does not work as i get an error!I am completely new to stored procedures so any help would be appreciated!Thank you!" |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2005-12-07 : 08:23:38
|
| Creating Table dynamically is not recommended though you can use Dynamic SQLCREATE PROCEDURE SP_CREATE_TABLE @table_name varchar(100)ASdeclare @Name varchar(100)set @Name=@table_nameEXEC('CREATE TABLE '+@Name+'(.....')MadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|