Counting the number of rows returned by stored procedure

前端 未结 7 1735
礼貌的吻别
礼貌的吻别 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条回答
  •  一向
    一向 (楼主)
    2021-01-03 23:26

    I have a similar task with a restriction that I must not alter the SP to get the count. Hence:

    sp_configure 'show advanced options', 1;  
    reconfigure;
    go
    
    sp_configure 'ad hoc distributed queries', 1;  
    reconfigure;  
    go
    
    select count(*) from 
        openrowset('SQLOLEDB','Data Source=localhost;Trusted_Connection=yes;
        Integrated Security=SSPI','exec DBNAME..SPName')
    

提交回复
热议问题