Sunday, 12 October 2014

@@ RowCount

@@ RowCount

It returns the number of rows affected by the last statement. If numbers are more than 2 billion then we have to use @@ ROWCOUNT_BIG.

The return value of this will be in Integer data type.

USE <DB Name>
GO
UPDATE <Table Name>
 SET <Column Value> = “Value”
IF @@ROWCOUNT = 0
PRINT 'Warning: No rows were updated';
GO


USE <DB Name>
GO
Insert into <Table Name> (Col1, Col2) values (‘Val1 for Col1’,’ Val1 for Col2’)
Select @@RowCount
GO

Keep Learning
Sanjay
mesanjaybakshi@gmail.com

No comments:

Post a Comment