Andy,
I am little confused with your requirement. As you say
Quote:
|
quote:What I want to do is to get a count of a select top query. The number of records I want to return is a variable so, as far as I'm aware
|
Select TOP 10 * from TESTTABLE order by Col1
Returns the top 10 records in the ascending order of the values present on COL1. I dont think you would get a count of records, as you had mentioned.
Quote:
quote:Set @sqlStatement = 'select TOP ' + convert(varchar, @numStatements) + ' Count(*) from [progressPDP].[dbo].[statementLabels] ORDER BY [labelIndex]'
@theCount = Execute (@sqlStatement)
|
An OUTPUTPARAMETER can hold a single values in it. Something like a count/value of a column based on sime criteria. It cannot hold a set of rows in it, as the code/pseudocode that you posted would return set of rows with two columns in its result, which cannot be stored in an output parameter.
May be you may want to re-post your requirement in an understandable way, so as it guide you in the right path.
Cheers!
-Vijay G