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

后端 未结 4 364
轮回少年
轮回少年 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

提交回复
热议问题