Execute Statement | SQL Server Performance Forums

SQL Server Performance Forum – Threads Archive

Execute Statement

I want to set the value returned by the count (using following execute statement) to an output parameter of an stored procedure….
How can I do this? Execute ("SELECT Count(*) FROM male_profiles WHERE ProfileID like ‘A%’") Regards
Gurpreet Sachdeva

The easiest way is to take the query and put it in a stored procedure. When you have done that, then you can use the RETURN statement to return the count value to a variable used within the EXECUTE statement, like so: EXECUTE @lintReturnValue=spWhatever spWhatever will be the query in your post, with the addition of a RETURN statement to return your count value
"How do you expect to beat me when I am forever?"
]]>