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 |
|
khufiamalik
Posting Yak Master
120 Posts |
Posted - 2008-08-20 : 02:01:02
|
| Is There any simple way to execute a query,Currently I have been using EXEC sp_executeSql and before calling it, I was just replacing the 1st Select with 'Select @output=' but when caller SP provided me a query likeWITH MyTable(Col1) as(select Col1 from table1union Select Col1 from table2)select Col1 from MyTable where MyConditionthe replacement logic is failed because it replaced the First Select which is written with in the WITHNow I am looking for any SP/Function that can execute my Query as it is(and I dont want to manipulate it) and it should give me the result in a variableIs there any solution for this????Thanks |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-08-20 : 02:07:28
|
| try this out:-replace(Yourquery,') select Col1',') Select @output= Col1') |
 |
|
|
|
|
|