Elements of Transact-SQL

Transact-SQL has several elements that are used by, or influence, most statements. This section provides the information necessary to understand and work with the various elements of Transact-SQL.

Transact-SQL element

Description

Identifiers

Names of objects such as tables, views, columns, databases, and servers.

Data Types

Define the types of data that are contained by data objects, such as columns, variables, and parameters. Most Transact-SQL statements do not reference data types explicitly, but the results of most statements are influenced by the interactions between the data types of the objects that are referenced in the statement.

Constants

Symbols that represent specific data types.

Functions

Syntax elements that take zero or one or more input values and return a scalar value or a tabular set of values. Examples include the SUM function for adding several values, the DATEDIFF function for determining how many units of time separate two dates, the @@SERVERNAME function for getting the name of an instance of Microsoft SQL Server, or the OPENQUERY function for executing a Transact-SQL statement against a remote server and retrieving the result set.

Expressions

Units of syntax that SQL Server can resolve to single values. Examples of expressions include constants, functions that return a single value, a reference to a column, or a variable.

Operators in Expressions

Work with one or more simple expressions to form a more complex expression. For example, the multiplication sign (*) in the expression PriceColumn *1.1 increases the price by 10 percent.

Comments

Pieces of text that are inserted into Transact-SQL statements or scripts to explain the purpose of the statement. The comments are not executed by SQL Server.

Reserved Keywords

Words that are reserved for use by SQL Server and should not be used for the names of objects in a database.