SQL Server Functions


SQL Server has many built-in functions.

This reference contains string, numeric, date, conversion, and some advanced functions in SQL Server.


SQL Server String Functions

Function Description
Returns the ASCII value for the specific character
Returns the character based on the ASCII code
Returns the position of a substring in a string
Adds two or more strings together
Adds two or more strings together
Adds two or more strings together with a separator
Returns the number of bytes used to represent an expression
Compares two SOUNDEX values, and returns an integer value
Formats a value with the specified format
Extracts a number of characters from a string (starting from left)
Returns the length of a string
Converts a string to lower-case
Removes leading spaces from a string
Returns the Unicode character based on the number code
Returns the position of a pattern in a string
Returns a Unicode string with delimiters added to make the string a valid SQL Server delimited identifier
Replaces all occurrences of a substring within a string, with a new substring
Repeats a string a specified number of times
Reverses a string and returns the result
Extracts a number of characters from a string (starting from right)
Removes trailing spaces from a string
Returns a four-character code to evaluate the similarity of two strings
Returns a string of the specified number of space characters
Returns a number as string
Deletes a part of a string and then inserts another part into the string, starting at a specified position
Extracts some characters from a string
Returns the string from the first argument after the characters specified in the second argument are translated into the characters specified in the third argument.
Removes leading and trailing spaces (or other specified characters) from a string
Returns the Unicode value for the first character of the input expression
Converts a string to upper-case


SQL Server Math/Numeric Functions

Function Description
Returns the absolute value of a number
Returns the arc cosine of a number
Returns the arc sine of a number
Returns the arc tangent of a number
Returns the arc tangent of two numbers
Returns the average value of an expression
Returns the smallest integer value that is >= a number
Returns the number of records returned by a select query
Returns the cosine of a number
Returns the cotangent of a number
Converts a value in radians to degrees
Returns e raised to the power of a specified number
Returns the largest integer value that is <= to a number
Returns the natural logarithm of a number, or the logarithm of a number to a specified base
Returns the natural logarithm of a number to base 10
Returns the maximum value in a set of values
Returns the minimum value in a set of values
Returns the value of PI
Returns the value of a number raised to the power of another number
Converts a degree value into radians
Returns a random number
Rounds a number to a specified number of decimal places
Returns the sign of a number
Returns the sine of a number
Returns the square root of a number
Returns the square of a number
Calculates the sum of a set of values
Returns the tangent of a number

SQL Server Date Functions

Function Description
Returns the current date and time
Adds a time/date interval to a date and then returns the date
Returns the difference between two dates
Returns a date from the specified parts (year, month, and day values)
Returns a specified part of a date (as string)
Returns a specified part of a date (as integer)
Returns the day of the month for a specified date
Returns the current database system date and time
Returns the current database system UTC date and time
Checks an expression and returns 1 if it is a valid date, otherwise 0
Returns the month part for a specified date (a number from 1 to 12)
Returns the date and time of the SQL Server
Returns the year part for a specified date

SQL Server Advanced Functions

Function Description
Converts a value (of any type) into a specified datatype
Returns the first non-null value in a list
Converts a value (of any type) into a specified datatype
Returns the name of the current user in the SQL Server database
Returns a value if a condition is TRUE, or another value if a condition is FALSE
Return a specified value if the expression is NULL, otherwise return the expression
Tests whether an expression is numeric
Returns NULL if two expressions are equal
Returns the name of the current user in the SQL Server database
Returns the session settings for a specified option
Returns the login name for the current user
Returns the database user name based on the specified id


Login
ADS CODE