Appendix C. T-SQL System Variables and Functions

Variables and functions are often used interchangeably. SQL Server Books Online documents some variables as though they were functions. However, it's important to note that variables are used in expressions to obtain a value, whereas functions process specific business logic and may return a value. Many functions accept input arguments.

This Appendix, specific for SQL Server 2008, is not meant to be a comprehensive reference, but to provide a convenient guide to many functions and variables. For complete details and samples of usage, consult Books Online.

System Global Variables

The system-supplied global variables are organized into the following categories:

  • Configuration

  • Cursor

  • System

  • System Statistics



Return Type




The system setting for the first day of the week:

  • 1 = Monday

  • 2 = Tuesday

  • 3 = Wednesday

  • 4 = Thursday

  • 5 = Friday

  • 6 = Saturday

  • 7 = Sunday

  • The U.S. default is 7.



The last assigned unique TimeStamp value



The current language ID for the server:

  • 0 = US English

  • 1 = German

  • 2 = French ...

  • and so on.



The current language string for the server. Returns the language name in the native language form (us_english, Deutsch, Français, Dansk, Español, Italiano, etc.).



Lock time-out setting for the current session in milliseconds (ms)



The maximum concurrent connections setting for the server



The maximum precision ...

Get Professional Microsoft® SQL Server® 2008 Reporting Services now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.