First, global variables
| Variable |
Meaning |
| @ @ERROR |
Error number of the last SQL error |
| @ @IDENTITY |
Last-inserted identity value |
| @ @LANGUAGE |
Language name currently in use |
| @ @MAX_CONNETIONS |
The maximum number of simultaneous connections that can be created |
| @ @ROWCOUNT |
Number of rows affected by the previous SQL statement (increment statement) |
| @ @SERVERNAME |
Name of the Local service |
| @ @SERVICENAME |
The name of the SQL service for this computer |
| @ @TIMETICKS |
The number of microseconds per scale for the current computer |
| @ @TRANSCOUNT |
Number of transactions opened by the current connection |
| @ @VERSION |
Version information for SQL Server |
eg.
1 --version information for 01SQL Sever2 Select @ @VERSION3 Print 'version information for SQL Sever' +@ @VERSION4 --Query Results Microsoft SQL Server R2 (RTM)-10.50.1600.1 (Intel X86) APR 2 15:53:02 Copyright (c) Microsoft Cor Poration Enterprise Edition on Windows NT 6.1 <X86> (Build 7601:service Pack 1)5 6 --02 Number of transactions open for the current link7 Declare @ @transcount nvarchar( +)8 Select @ @transcount 9 --query result is nullTen One --03 Number of microseconds per tick on the current computer A Select @ @timeticks - --Query Result 31250 - the --04 SQL Service name on the computer - Select @ @SERVICENAME - --Query result MSSQLServer - + --05 name of the Local service - Select @ @SERVERNAME + --Query Result 123-pc A at --06 marked value for last insertion - Insert intoStudentValues(111111,'Ming',1,2,12345678912,'Beijing','1996-1-11','@123', One) - Select @ @IDENTITY - - --07 number of rows affected - Insert intoStudentValues(111111,'Ming',1,2,12345678912,'Beijing','1996-1-11','@123', One) in Select @ @ROWCOUNT - to --08 can be created, at the same time the maximum number + Select @ @MAX_CONNECTIONS fromStudent - the --09 Name of the language currently in use * Select @ @LANGUAGE $ Panax Notoginseng --10 last T-SQL error number - Insert intoStudentValues(111111,'Ming',1,2,12345678912,'Beijing','1996-1-11','@123','NULL')---' null ' cannot be a string the Select @ @ERROR
Description and illustration of global variables