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.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Rewrite parameters to use dynamic sql??

Author  Topic 

uberman
Posting Yak Master

159 Posts

Posted - 2009-07-31 : 10:35:36
Just read the following

[url]http://www.databasejournal.com/features/mssql/article.php/3830981/T-SQL-Best-Practices--Part-2.htm[/url]

I can't fault the logic but something about it just seems wrong, is sp_executesql really the best way to handle multiple parameters?

Lamprey
Master Smack Fu Yak Hacker

4614 Posts

Posted - 2009-07-31 : 13:50:21
I'm not a fan of dynamic sql, but when it comes to queries with optional parameters it is, more times than not, going to be faster. If you are going to go the dynamic sql route, then sp_executesql is the best way to do it in my opinion.
Go to Top of Page
   

- Advertisement -