>>I've always used SQLParameter as well and it executed sp_executesql behind the scenes anyway.
>>
>>So, what exactly you would try to send to SQL Server?
>
>Yes, SQL Profiler shows it as is. But, when I executed it as is in SSMS, it was a little bit faster than with the DECLARE approach.
>
>Basically, the initial topic was about performance. So, I wanted to verify that the SQLParameter object was not a factor here. It turned out that running those queries with OPTION (RECOMPILE) resolved the issue. I just don't know why SQL Server on specific queries will start crawling but with that option it fixed it.
I believe I read about it recently on the other forum I pointed you to originally. I would not have time to search for this today, I'm afraid, but in few days I may try to find that thread for you there.
If it's not broken, fix it until it is.
My Blog