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

Configuration

Variable

Return Type

Description

@@DATEFIRST

tinyint

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.

@@DBTS

varbinary

The last assigned unique TimeStamp value

@@LANGID

smallint

The current language ID for the server:

  • 0 = US English

  • 1 = German

  • 2 = French ...

  • and so on.

@@LANGUAGE

nvarchar

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_TIMEOUT

int

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

@@MAX_CONNECTIONS

int

The maximum concurrent connections setting for the server

@@MAX_PRECISION

tinyint

The maximum precision ...

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

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.