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 - 2001-10-18 : 09:39:26
|
| Djamal writes "With the following stored procedure, MyProc, I would like to dynamically create a table which name is passed as a parameter and fill it with the result of a call to xp_cmdshell. But if I execute MyProc, I will get an empty table.What's wrong with it and how can I correct it?Create Procedure MyProc @TableName VarChar(100)ASDeclare @SQL VarChar(1000)Declare @cmd VarChar(1000)SELECT @SQL = 'Create Table ' + @TableName + '('SELECT @SQL = @SQL + 'Data VarChar(10))'Exec (@SQL)SELECT @SQL = 'INSERT ' + SELECT @cmd = 'testCMD hello'Exec ( @SQL)Exec xp_cmdshell @cmdGO" |
|
|
|
|
|