August 2012
Intermediate to advanced
1416 pages
33h 39m
English
You can construct SQL expressions from a nearly limitless list of constants, variables, operators, and functions, as detailed in Table 8.5.
Table 8.5 Building Expressions
| Expression Components | Examples |
| Numeric constants | 1, 2, 3, -17, -100 |
| String literals | ‘LastName', ‘Employee: ‘, ‘Lifes Great!' |
| Dates | ‘1/30/1980', ‘January 30, 1980', ‘19800130' |
| Mathematical operators (in order of precedence) | *, /, % (remainder), +, - |
| String operator (concatenation) | + |
| Bitwise operators (in order of precedence) | not, and &, or |, exclusive or |
| Columns | LastName, PrimaryKeyID |
| Case expressions | CASE Column1 WHEN 1 THEN ‘on' ELSE ‘off' END AS Status |
| Subqueries | (Select 3) |
| User-defined variables | @MyVariable |
| System functions | @@Error |
| Scalar functions | GetDate(), Radians() |
| User-defined functions | dbo.MyUDF() |
One thing that should be noted is the use of @, which is part of the variable declaration. ...
Read now
Unlock full access