Click here to Skip to main content
15,891,184 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
See more:
Is there a way to dynamically create Tsql query in stored procedure.
i know about creating a query ia a varchar variable and execute it using
sp_executesql
or
EXECUTE
but it seems to be hard to debug if query gets complicated
Posted
Updated 2-Jun-11 21:52pm
v2
Comments
shahbaz khurram 3-Jun-11 8:59am    
I m also looking for the alternative but have no luck yet

1 solution

You practically do the same way in stored procedures if you are to create dynamic TSQL scripts. My advice is, as much as possible, try to avoid dynamic SQL if you can do it without one. Its said they're a lot slower than non-dynamic scripts.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900