Counting the number of rows returned by stored procedure

前端 未结 7 1734
礼貌的吻别
礼貌的吻别 2021-01-03 23:11

How do I count the number of rows a stored procedure would return the fastest way. Stored procedure returns rows around 100K to 1M records.

7条回答
  •  Happy的楠姐
    2021-01-03 23:24

    So far the only thing that has worked for me is to:

    a. Modify momentarily the stored procedure to dump the resulting dataset into a table. If changing the stored procedure is not an option replace Alter Procedure with Declare and remove the end, provide parameter values if not optional and execute as a query dumping the dataset into a table.

    b. Script the table and drop it using SSMS.

    c. Use the script to create a virtual table in the query and use Insert into with exec stored procedure to populate it.

    d. Count the records.

提交回复
热议问题