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
 General SQL Server Forums
 New to SQL Server Administration
 EXEC <stored_procedure> and T-SQL inside the SP

Author  Topic 

benildusmuerling
Yak Posting Veteran

81 Posts

Posted - 2012-06-27 : 23:38:25
Hi All,

Thanks for reading my post, can someone explain, after creating a stored procedure, and at the time of running it with
exec <storedproedure> it does not take that many time, however when I open the stored procedure and run it by T-SQL it takes heaps of time.

How am I suppose to create the stored procedure, by doing a bit of testing, before creating and sending the stored proc to the database.

PS : bottom line, I would like to want to know, the reason behind proc, when run by exec <sp> is fast, and when expanding it and running it by the T-SQL takes ages.

Thanks,

AB

jackv
Master Smack Fu Yak Hacker

2179 Posts

Posted - 2012-06-28 : 01:43:26
1) Are you running both from the same basis i.e DBCC FREEPROCCACHE and DBCC DROPCLEANBUFFERS? before each statement?
2)are the defaults different ? such as SET ANSI_NULLS OFF etc?
3)Have you checked the Execution Plan of both? are they the same?

Jack Vamvas
--------------------
http://www.sqlserver-dba.com
Go to Top of Page
   

- Advertisement -