Tuesday, May 5, 2009

Need of SET NOCOUNT in SQL SERVER SPROCS

In every stored procedure we have define a common syntax is SET NOCOUNT ON/OFF. But most of us don't have any idea of why are we using it.
It is useful because of knowing the number of rows effected by some t-sql statement.

"Stops the message indicating the number of rows affected by a Transact-SQL statement from being returned as part of the results."

Syntax is: SET NOCOUNT {ON | OFF}

When SET NOCOUNT is ON, the count (indicating the number of rows affected by a Transact-SQL statement) is not returned. When SET NOCOUNT is OFF, the count is returned.

No comments:

Post a Comment