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 2000 Forums
 Transact-SQL (2000)
 sp_ExecuteSQL vs EXEC()

Author  Topic 

SoftFox
Starting Member

42 Posts

Posted - 2008-02-05 : 05:34:53
Is there any advantage to using sp_ExecuteSQL instead of just EXEC to execute a SQL string? E.g

DECLARE @ExecStr nVARCHAR(300)
SET @ExecStr = 'SELECT TOP 10 * FROM LCSearchRequests'

--both give same result. Is one better than the other?
exec sp_ExecuteSQL @ExecStr

exec(@ExecStr)

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2008-02-05 : 05:53:25
do not cross post!

_______________________________________________
Causing trouble since 1980
blog: http://weblogs.sqlteam.com/mladenp
SSMS Add-in that does a few things: www.ssmstoolspack.com <- new version out
Go to Top of Page
   

- Advertisement -