Global Variables in MSSQL

MSSQL has a few variables that had to be noticed. Whenever a variable starts with "@@" it is a global variable. There are many such variables. We will have a short description of important members of the global variable family:

    @@ERROR Returns the error number for the last Transact-SQL statement executed. @@ERROR is set to 0 if the statement executed successfully.
    @@FETCH_STATUS is the variable which stores the cursor position. Because @@FETCH_STATUS is global to all cursors on a connection, use @@FETCH_STATUS carefully. After a FETCH statement is executed, the test for @@FETCH_STATUS must occur before any other FETCH statement is executed against another cursor. The value of @@FETCH_STATUS is undefined before any fetches have occurred on the connection.
    @@Identity is the identity variable, which stores the identity column's value of the last affected row by an insert/bulk-copy statement. After an INSERT, SELECT INTO, or bulk copy statement completes, @@IDENTITY contains the last identity value generated by the statement. If the statement did not affect any tables with identity columns, @@IDENTITY returns NULL.
    @@ROWCOUNT is the global variable which stores the number of rows affected by the last sql query executed on the database server.

Hosted by www.Geocities.ws

1