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 |
sarathi125
Starting Member
3 Posts |
Posted - 2010-08-18 : 03:20:20
|
Hi All,I need to execute a sql query in my stored procedure.That means I want to pass a SQL Query from my application to my stored procedure and need to execute it in the stored procedure.The Query is a dynamic one, so each time the stored procedure have to write different values.See the below sample and advise me the right thing to reach this.Alter procedure CustomFilterQuery@query varchar(max)As BEGINEXECUTE @queryENDHere i'm trying to execute the stored procedure but it throws error likeEXECUTE CustomFilterQuery 'select * from Orders'Msg 2812, Level 16, State 62, Procedure CustomFilterQuery, Line 5Could not find stored procedure 'select * from Orders'. |
|
Shilpa22
Starting Member
37 Posts |
Posted - 2010-08-18 : 03:24:22
|
try Exec(@query)Thanks in AdvanceShilpa |
 |
|
sarathi125
Starting Member
3 Posts |
Posted - 2010-08-18 : 03:27:01
|
quote: Originally posted by Shilpa22 try Exec(@query)Thanks in AdvanceShilpa
Hi,Yes, Its working fine.Thanks for your time.Is it possible to send the query with condition and values... |
 |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
|
|
|
|