Skip to content
Advertisement

How to get Output parameter from a column in table for a stored procedure

I’ve stored procedure like this:

We can execute the above stored procedure by:

The written sp provides data based on pagination and we can retrieve 100 or any number of records by passing a number in @int_grid_size .

The table output looks like following:

The last column gives the total records count of the table or total record if we use where condition.

I want to OUTPUT any one column value of the totalRowCount in ‘@count’ in the stored procedure.

I cannot use @@ROWCOUNT as it only sends the count of records the sp is outputting i.e in this case 5 but actual records are 107.

Just wondering if there is any way. Any help is apperciated. Thanks.

Edit:

I tried something like this, and it works:

The issue with this is I’ve to call the query once and then call the query again for @count. This is working but taking lot of time for big queries.

Advertisement

Answer

You can do that by temp table

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement