SQL Server Performance

Execute Statement

Discussion in 'T-SQL Performance Tuning for Developers' started by sachson, Feb 5, 2003.

  1. sachson New Member

    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%'")

    Gurpreet Sachdeva
  2. royv New Member

    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?"

Share This Page