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 |
|
susan_151615
Yak Posting Veteran
99 Posts |
Posted - 2009-01-08 : 05:19:31
|
| Hi i want to assign a delete query to variable and i have to execute it.and i have done it like this inside the SP:declare @vTrun varchar(128)set @vTRUN="DELETE FROM UST_SAMP_DETAILS"exec @vTRUNThe SP is been compiled successfully but while executingit taking the statement "set @vTRUN="DELETE FROM UST_SAMP_DETAILS"exec @vTRUN" as an SP and its throwing an error stating:Could not find stored procedure 'DELETE FROM UST_SAMP_DETAILS'.So can anyone tell me how to execute a variable to which i assign a delete query statementsusan |
|
|
sakets_2000
Master Smack Fu Yak Hacker
1472 Posts |
Posted - 2009-01-08 : 05:24:35
|
you could simply put DELETE FROM UST_SAMP_DETAILS , Why make it dynamic?Incase you are just trying to test something, you could alter it todeclare @vTrun varchar(128)set @vTRUN='DELETE FROM UST_SAMP_DETAILS'exec (@vTRUN) |
 |
|
|
Transact Charlie
Master Smack Fu Yak Hacker
3451 Posts |
Posted - 2009-01-08 : 05:30:38
|
to answer the original question:You have to useEXEC (@vTRUN) note the bracketsHowever, sakets makes a valid point -- why do this?Charlie===============================================================Msg 3903, Level 16, State 1, Line 1736The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION |
 |
|
|
susan_151615
Yak Posting Veteran
99 Posts |
Posted - 2009-01-08 : 05:51:02
|
| Hi thank u so much to both of you .Its working fine nowsusan |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-01-08 : 08:30:05
|
quote: Originally posted by susan_151615 Hi thank u so much to both of you .Its working fine nowsusan
you still didnt answer the question asked..whats the purpose? |
 |
|
|
|
|
|