What is use of @@ROWCOUNT in T-Sql with Procdure?
Loading
What is use of @@ROWCOUNT in T-Sql with Procdure?
CREATE PROCEDURE UpdateEmployees@LastName nvarchar(50),@Salary decimal(10,2)ASBEGINUPDATE EmployeesSET Salary = @SalaryWHERE LastName = @LastNameSELECT @@ROWCOUNT AS NumRowsAffectedEND
In this stored procedure, we are updating the Salary column of the Employees table for all employees with the specified LastName. After the UPDATE statement, we are using @@ROWCOUNT to return the number of rows that were affected by the UPDATE statement.
@@ROWCOUNT is a system function in T-SQL that returns the number of rows affected by the last statement executed.
In the context of a stored procedure, @@ROWCOUNT can be used to determine the number of rows affected by a particular SQL statement within the procedure. For example, if you have an UPDATE statement that modifies some rows in a table, you can use @@ROWCOUNT to determine the number of rows that were actually updated.