Sql Server functions:
Category | Type | Function name | Description |
---|---|---|---|
String | ASCII(x) | Convert character x to ASCII | |
String | CHAR(x) | Convert ASCII x to character | |
String | + | String concatenate | |
String | CHARINDEX(search, str[, start]) | Find first occurrence of substring search in str, starting from start | |
String | PATINDEX(search, str) | Find first occurrence of pattern search in string str | |
String | LOWER(x) | Convert x to lowercase | |
String | UPPER(x) | Convert x to uppercase | |
String | LTRIM | Remove leading blank spaces from x | |
String | RTRIM | Remove trailing blank spaces from x | |
String | LTRIM(RTRIM(x)) | Remove leading and trailing blanks from x | |
String | REPLICATE | Repeat str n times | |
String | SPACE(n)String of n spaces | ||
String | STR | Convert number to string | |
String | SUBSTRING(str, start, length) | Substring from string str, starting from start, length of len | |
String | REPLACE | Replace characters (MSSQL by default works case insensitively) | |
String | LEN(x) | Length of string x (in characters) | |
String | DATALENGTH(x) | Length of string x (in bytes) | |
String | QUOTENAME(x, '''') | Quote SQL in string x | |
String | SOUNDEX(x) | Soundex index of string x | |
Conversion | CAST (expression AS datatype) | ||
Conversion | CONVERT (datatype, expression) | ||
DateTime | GETDATE() | Get Current Date | |
DateTime | DATEADD (datepart, number, date) | Date addition | |
DateTime | DATEDIFF (datepart, start, end) | Date subtraction | |
DateTime | DATEDIFF (datepart, start, end) | Date difference | |
DateTime | DATENAME (datepart, date) | Convert date to string | |
DateTime | DATEPART (datepart, date) | Convert date to number | |
DateTime | CAST | Convert string to date | |
DateTime | GETUTCDATE() | Current Date | |
DateTime | DAY (date)Current day | ||
DateTime | MONTH (date)Current month | ||
DateTime | YEAR (date) | Current year | |
Aggregate | COUNT([DISTINCT] x) | Count non-NULL values in x | |
Aggregate | SUM([DISTINCT] x) | Sum of x | |
Aggregate | AVG([DISTINCT] x) | Average of x | |
Aggregate | MIN(x) | Minimum value in x | |
Aggregate | MAX(x) | Maximum value in x | |
Aggregate | STDEV(x) STDEVP(x) |
Standard deviation | |
Aggregate | VAR(x) VARP(x) |
Variance | |
Numeric | ABS(x) | Absolute value of x | |
Numeric | SIGN(x) | Sign of number x | |
Numeric | x % y | Modulus (remainder) of x / y | |
Numeric | CEILING(x) | Smallest integer >= x | |
Numeric | FLOOR(x) | Largest integer <= x | |
Numeric | ROUND(x[, d]) | Round x (to precision of d digits) | |
Numeric | SQRT(x) | Square root | |
Numeric | EXP(x) | Exponent of x (ex) | |
Numeric | POWER(x, y) | Power (xy) | |
Numeric | LOG(x) | Natural logarithm of x | |
Numeric | LOG10(x) | Logarithm, base 10 | |
Numeric | RAND(x) | Randomize, set seed to x | |
Numeric | RAND() | Generate random number | |
Numeric | COALESCE(val1, val2, ...) | Return the first non-NULL value from a list of values | |
Numeric | ISNULL(val1, val2) | ||
Numeric | NULLIF(val1, val2) | Return NULL if two values are equal | |
Trigonometric | ASIN(x) | Arc sine | |
Trigonometric | ACOS(x) | Arc cosine | |
Trigonometric | ATAN(x) | Arc tangent of x | |
Trigonometric | ATN2(x, y) | Arc tangent of x and y | |
Trigonometric | SIN(x) | Sine | |
Trigonometric | COS(x) | Cosine | |
Trigonometric | TAN(x) | Tangent | |
Trigonometric | COT(x) | Cotangent |