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 |
|
iswan
Starting Member
28 Posts |
Posted - 2007-04-05 : 03:42:40
|
| How create the table using procedure or function. the table name comes from a procedure as parameter Code: i triedcreate procedure #Isw_tab @TableName VARCHAR(1000)asEXEC ('CREATE TABLE '+@TableName+'(Age int)')exec #Isw_tab '#isw1';It is not creating the table |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-04-05 : 03:55:01
|
| That should be the bad db designWhy do you need to create tables on the fly?Pre-create the table and access data through the procedureMadhivananFailing to plan is Planning to fail |
 |
|
|
iswan
Starting Member
28 Posts |
Posted - 2007-04-05 : 04:02:21
|
| I get the Table name, Field name from the front end (i.e Asp page). So I need to create the table or alter the table through procedureIswan |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-04-05 : 04:18:46
|
quote: Originally posted by iswan I get the Table name, Field name from the front end (i.e Asp page). So I need to create the table or alter the table through procedureIswan
Thats what I told you that is the bad designWhy do you need this?Can you give me practical example for this?Note that with this approach, your interaction with dataase will become too complex with too much use of dynamic sqlAlso before dynamically executing, print that sql and see if the statement is validMadhivananFailing to plan is Planning to fail |
 |
|
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2007-04-05 : 04:22:56
|
Whoa!!!1. Creating temporary stored procedure2. Passing table name as parameter3. Creating table dynamically from SP 4. The table that needs to be created is local temp table!There are too much loose ends here ...I am leaving !Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
 |
|
|
|
|
|