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 |
|
jogin malathi
Posting Yak Master
117 Posts |
Posted - 2007-06-27 : 05:36:59
|
| Hi allI want to create table in stored procedureas followsis this correctCREATE PROCEDURE dbo.StoredProcedure5 @p1 varchar(50), @p2 varchar(50), @d1 varchar(50), @d2 varchar(50)AS create table t1(@p1 @d1,@p2,@d2)Thanks In AdvanceMalathi Rao |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2007-06-27 : 05:39:37
|
| No.Have a look at dynamic sql.It's a bad idea to attempt it.==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
jogin malathi
Posting Yak Master
117 Posts |
Posted - 2007-06-27 : 05:40:31
|
quote: Originally posted by nr No.Have a look at dynamic sql.It's a bad idea to attempt it.==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy.
sorry and thanxMalathi Rao |
 |
|
|
jogin malathi
Posting Yak Master
117 Posts |
Posted - 2007-06-27 : 05:42:43
|
quote: Originally posted by nr No.Have a look at dynamic sql.It's a bad idea to attempt it.==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy.
Can u give one small example and helpMalathi Rao |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-06-27 : 06:37:02
|
| Why do you want to create a table based on the column names passed to the procedure?You will end up with too much dynamic sqlExplain what you are trying to doMake sure you read this fullywww.sommarskog.se/dynamic_sql.htmlMadhivananFailing to plan is Planning to fail |
 |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2007-06-27 : 07:19:56
|
| CREATE PROCEDURE dbo.StoredProcedure5 @p1 varchar(50),@p2 varchar(50),@d1 varchar(50),@d2 varchar(50)ASexec ('create table t1(' + @p1 + @d1 + ',' + @p2+ @d2+ ')')godepends on what is in the parameters.It's still a bad idea.==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
|
|
|