0

In SQL Server is there a way to have an output parameter return the total number of records (for paging) in a parameterized query?

adam0101
  • 29,096
  • 21
  • 96
  • 174

2 Answers2

3

A stored procedure can have an output parameter, but not a standard query. You could execute an initial query to get the record count, or return mutliple results sets from one query.

cjk
  • 45,739
  • 9
  • 81
  • 112
0

No, but You can do something like that:

SELECT
**,
COUNT(*) OVER(PARTITION BY ID)
FROM TABLE

Not very pretty, but returns record count. You can also use ROW_NUMBER().

LukLed
  • 31,452
  • 17
  • 82
  • 107