Sproc execution is much slower than ad-hoc SQL equivalent
I have a sproc that was taking much longer than I expected.
I pulled out the SQL and ran it with only DECLARED variables for the parameters. It worked almost instantaneously (compared to the reliable 8 seconds with sproc). This is the same SQL on the same machine, returning the same data.
How can I identify and fix what is causing the slow sproc?
It's on SQL Server Express.
Many thanks.
+2
source to share