@@fetch_status is 0 if a record was fetched and non 0 otherwise. @@options @@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'
@@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. serverproperty('ServerName') and @@servicename. @@servicename returns the name of the registry key below HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server under which an instance is running. MSSQL$. @@servicename and the name of the Windows service are equal: MSSQLSERVER. @@servername. @@spid stores the current session id. @@trancount counts the nested transactions. @@version returns the version of the currently installed SQL Server.