Search notes:

SQL Server: @@-variables

@@fetch_status

After fetching from a cursor, @@fetch_status is 0 if a record was fetched and non 0 otherwise.

@@identity

See scope_identity(), @@identy and ident_current.

@@options

See @@options

@@rowcount

@@rowcount stores how many recores were affected or read in the most recent sql statement.
update tq84_foo set col_1 = @col_val where id = @foo_id;
if @@rowcount = 0
   print 'No rows were updated'
The Oracle equivalent for @@rowcount seems to be %rowcount.

@@servername

@@servername stores the name of the server. This is the value that is needed for the -S option in sqlcmd.exe to connect to a specific instance.
Compare with serverproperty('ServerName') and @@servicename.

@@servicename

@@servicename returns the name of the registry key below HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server under which an instance is running.
Note: for non default services, the Windows service that runs on behalv of the instance is prefixed with MSSQL$.
For the default instance, both values, @@serivcename and the name of the Windows service are equal: MSSQLSERVER.
Compare with @@servername.

@@spid

@@spid stores the current session id.
@@spid can be joined to the column spid in sys.sysprocesses.

@@trancount

@@trancount counts the nested transactions.

@@version

@@version returns the version of the currently installed SQL Server.

See also

SQL Server: variables

Index