Friday, March 9, 2012

Help - using sp_executesql with dynamic query...dynamic parameters?

[posted and mailed, please reply in news]
Lisa Forde (1forde@.caribsurf.com) writes:
> Hi. I'm attempting to write a Stored Procedure that creates an SELECT
> statement. Belwo is an example of what I am tryign except that my actually
> query have many more parameters most of which can be eliminated.
>...
> EXEC sp_executesql @.sQuery,@.sParams, <WHAT DO I PUT HERE'>
> Can it even work?
You put the parameters. I have an example of a dynamic search routine
at http://www.sommarskog.se/dyn-search.html#sp_executesql which hopefully
can be of help for you.
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.aspPerfect!
Thanks.
"Erland Sommarskog" <esquel@.sommarskog.se> wrote in message
news:Xns96F7A82091A39Yazorman@.127.0.0.1...
> [posted and mailed, please reply in news]
> Lisa Forde (1forde@.caribsurf.com) writes:
actually
> You put the parameters. I have an example of a dynamic search routine
> at http://www.sommarskog.se/dyn-search.html#sp_executesql which hopefully
> can be of help for you.
>
> --
> Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
> Books Online for SQL Server SP3 at
> http://www.microsoft.com/sql/techin.../2000/books.asp
>

No comments:

Post a Comment