The language of the Database Engine, Transact-SQL, has the same basic features as other common programming languages: Literal values (also called constants) Delimiters Comments Identifiers Reserved keywords The following sections describe these features. Literal Values A literal value is an alphanumerical, hexadecimal, or numeric constant. A string constant contains one or more characters of the… [Continue Reading]
SQL Components - SQL Server 2012
This chapter introduces the elementary objects and basic operators supported by the Transact-SQL language. First, the basic language elements, including constants, identifiers, and delimiters, are described. Then, because every elementary object has a corresponding data type, data types are discussed in detail. Additionally, all existing operators and functions are explained. At the end of the chapter, NULL values are introduced.
Data Types (Numeric, Character, Temporal etc)
All the data values of a column must be of the same data type. (The only exception specifies the values of the SQL_VARIANT data type.) Transact-SQL uses different data types, which can be categorized as follows: Numeric data types Character data types Temporal (date and/or time) data types Miscellaneous data types The following sections describe… [Continue Reading]
Storage Options (FILESTREAM, Sparse columns)
Since SQL Server 2008, there are two different storage options, each of which allows you to store LOBs and to save storage space: FILESTREAM Sparse columns The following subsections describe these options. FILESTREAM Storage As you already know, SQL Server supports the storage of LOBs using the VARBINARY(max) data type. The property of this data… [Continue Reading]
Transact-SQL Functions (Aggregate, Scalar)
Transact-SQL functions can be either aggregate functions or scalar functions. The following sections describe these function types. Aggregate Functions Aggregate functions are applied to a group of data values from a column. Aggregate functions always return a single value. Transact-SQL supports several groups of aggregate functions: Convenient aggregate functions Statistical aggregate functions User-defined aggregate functions… [Continue Reading]
Scalar Operators, Global Variables
Scalar operators are used for operations with scalar values. Transact-SQL supports numeric and Boolean operators as well as concatenation. There are unary and binary arithmetic operators. Unary operators are + and – (as signs). Binary arithmetic operators are +, –, *, /, and %. (The first four binary operators have their respective mathematical meanings, whereas… [Continue Reading]
NULL Values in SQL Server
A NULL value is a special value that may be assigned to a column. This value normally is used when information in a column is unknown or not applicable. For example, in the case of an unknown home telephone number for a company’s employee, it is recommended that the NULL value be assigned to the… [Continue Reading]