devxlogo

Using the @@rowcount Global Variable in SQL

Using the @@rowcount Global Variable in SQL

After each Transact-SQL statement, the server sets the value of this variable to the total number of records affected by it. It can be used to verify the success of selected operations:

SQL Server sets the value of the @@rowcount variable after each T-SQL statement to the total number of records affected by the statement. The @@rowcount variable is usually used to verify success of a certain query. Here is a small example:

SELECT ID, StudentName, StudentSurname, StudentAgeINTO AugustStudentsFROM CurrentStudentsWHERE CourseFinishDate 
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist