Below is my query
select
@monNameStr as [MName],
IsNull(count(c.AssignmentID),0),
IsNull(sum(s.ACV),0),
IsNu
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
select @@ROWCOUNT
(e.g. Counting the number of deleted rows in a SQL Server stored procedure )
You can just use `@@ROWCOUNT` to get the records affected/returned
DECLARE @rowsreturned INT
SET @rowsreturned = @@ROWCOUNT
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.