Click here to Skip to main content
15,888,579 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi I have a stored procedure and when i run it by using declare and set parameter it gives me result with in 38 seconds but if i use (exec sp_procedurename parametervalue1,parametervalue2) statement then it takes 5 minutes to execute.



Please help me how could i resolve this problem.?
Posted

Thanks

Now i am getting the result in less time.
 
Share this answer
 
If you're running the same exact SQL as the stored procedure and the times are that different, your stored procedure is probably relying on metadata that is out of date. Try updating statistics or recompiling the stored procedure.

Please see this link: http://social.msdn.microsoft.com/Forums/sqlserver/en-US/ba4b81cd-211c-4716-ba84-19ef2c8290e4/stored-procedure-slower-than-running-query-in-sql-server-management-studio[^]

http://stackoverflow.com/questions/13750829/stored-procedure-runs-much-slower-than-query[^]
 
Share this answer
 
v2

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