1 overview
This article mainly outlines SQL Server expressions.
2 Specific content
2.1 Scope of Use
SQL Server (2008 start); Azure SQL database; Azure SQL data Warehouse; Parallel Data Warehouse
2.2 Syntax
is a combination of symbols and operators that are evaluated by the SQL Server database engine to obtain a single data value. a simple expression can be a single constant, variable, column, or scalar function. operators can be used to connect two or more simple expressions to a complex expression.
1 --Syntax for SQL Server and Azure SQL Database2 3{constant|Scalar_function| [table_name.] column |variable4 |(expression)|(scalar_subquery)5 |{unary_operator} expression6 |expression {binary_operator} expression7 |Ranking_windowed_function|aggregate_windowed_function8}
1 --Syntax for Azure SQL data Warehouse and Parallel data Warehouse2 3 --Expression in a SELECT statement4 <Expression>::= 5 { 6 constant7 |scalar_function8 | column 9 |variableTen |(expression) One |{unary_operator} expression A |expression {binary_operator} expression - } - [COLLATE Windows_collation_name] the - --Scalar Expression in a DECLARE, SET, IF ... ELSE, or while statement - <Scalar_expression>::= - { + constant - |scalar_function + |variable A |(expression) at |(scalar_subquery) - |{unary_operator} expression - |expression {binary_operator} expression - } - [COLLATE {windows_collation_name]
2.3 Parameters
President
2.4 Expression Results
For simple expressions consisting of a single constant, variable, scalar function, or column name: The data type, collation, precision, scale, and value of the expression are data types, collation, precision, scale, and value reference elements.
When you combine two expressions by using a comparison or logical operator, the resulting data type is Boolean, which is one of the following: True,false or unknown. For more information about Boolean data types, see comparison operators (Transact-SQL).
When using arithmetic, bitwise OR string operators combine two expressions, the operator determines which data type is generated.
Complex expressions consisting of many symbols and operators are evaluated as single-valued results. By combining expressions to determine the data type, collation, precision, and value of the generated expression, two times each time until the final result is reached. The order of the combinations of expressions is defined by the precedence of the operators in the expression.
2.5 notes
3 references
"01" Https://docs.microsoft.com/zh-cn/sql/t-sql/language-elements/expressions-transact-sql
4 Copyrights
- Thank you for your reading, if there are shortcomings, welcome advice, common learning and common progress.
- Bo main website: http://www.cnblogs.com/wangjiming/.
- A very small number of articles using reading, reference, reference, copying, copying and pasting into a variety of ways, most of the original.
- If you like, please recommend, if you have new ideas, welcome, email: [Email protected].
- The blog can be reproduced, but must be well-known from the blog source.
SQL Server series expressions (expression)