

It's not EXEC'ing that statement, simply performing a select. 3 Answers Sorted by: 31 You can use spexecutesql with an output parameter to retrieve the scalar result. You EXEC your current proc and pass it vars, and it returns a value BASED ON the select statement it runs.

#Exec t sql full#
Well, I think to answer the full question, I don't believe a stored procedure would EXEC a SELECT statement, it would simply perform the SELECT. exec (sql) Why did lobodava pick exec spexecutesql sql and not exec (sql) So what is the difference here Is it better to use spexecutesql on recursive dynamic queries In other post they say spexecutesql is more likely to promote query plan reuse.
