Getting no. of rows affected after running select query in SQL Server 2005

后端 未结 4 361
轮回少年
轮回少年 2021-01-18 15:54

Below is my query

select    
@monNameStr as [MName],             
IsNull(count(c.AssignmentID),0),                
IsNull(sum(s.ACV),0),               
IsNu         


        
相关标签:
4条回答
  • 2021-01-18 16:12

    capture @@ROWCOUNT into a variable, because it will change values each time you select it:

    DECLARE @Rows   int
    
    ---your query here
    
    SELECT @Rows=@@ROWCOUNT
    

    you can then use it as necessary as @Rows

    0 讨论(0)
  • 2021-01-18 16:12
    select @@ROWCOUNT 
    

    (e.g. Counting the number of deleted rows in a SQL Server stored procedure )

    0 讨论(0)
  • 2021-01-18 16:24
    You can just use `@@ROWCOUNT` to get the records affected/returned
    
    DECLARE @rowsreturned INT
    SET @rowsreturned = @@ROWCOUNT
    
    0 讨论(0)
  • 2021-01-18 16:25

    You can check the value of @@ROWCOUNT after the query has run. See http://technet.microsoft.com/en-us/library/ms187316.aspx for more info.

    0 讨论(0)
提交回复
热议问题