1/22/25, 5:55 PM SQL Server Functions
Tutorials Exercises Certificates Services Search... Sign Up Log in
HTML
CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C C++ C# BOOTSTRAP R
SQL Server Functions
❮ Previous Next ❯
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
ASCII Returns the ASCII value for the specific character
CHAR Returns the character based on the ASCII code
CHARINDEX Returns the position of a substring in a string
CONCAT Adds two or more strings together
https://www.w3schools.com/sql/sql_ref_sqlserver.asp 1/13
1/22/25, 5:55 PM SQL Server Functions
ConcatTutorials
with +
Exercises
Adds two or more strings together
Certificates Services Sign Up Log in
CONCAT_WS Adds two or more strings together with a separator
HTML
CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C C++ C# BOOTSTRAP R
DATALENGTH Returns the number of bytes used to represent an expression
DIFFERENCE Compares two SOUNDEX values, and returns an integer value
FORMAT Formats a value with the specified format
LEFT Extracts a number of characters from a string (starting from left)
LEN Returns the length of a string
LOWER Converts a string to lower-case
LTRIM Removes leading spaces from a string
NCHAR Returns the Unicode character based on the number code
PATINDEX Returns the position of a pattern in a string
QUOTENAME Returns a Unicode string with delimiters added to make the string a valid SQL Server
delimited identifier
REPLACE Replaces all occurrences of a substring within a string, with a new substring
REPLICATE Repeats a string a specified number of times
REVERSE Reverses a string and returns the result
RIGHT Extracts a number of characters from a string (starting from right)
RTRIM Removes trailing spaces from a string
SOUNDEX Returns a four-character code to evaluate the similarity of two strings
https://www.w3schools.com/sql/sql_ref_sqlserver.asp 2/13
1/22/25, 5:55 PM SQL Server Functions
SPACETutorials Exercises
Returns a string of the specified number of space characters
Certificates Services Sign Up Log in
STR Returns a number as string
HTML
CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C C++ C# BOOTSTRAP R
STUFF Deletes a part of a string and then inserts another part into the string, starting at a
specified position
SUBSTRING Extracts some characters from a string
TRANSLATE 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.
TRIM Removes leading and trailing spaces (or other specified characters) from a string
UNICODE Returns the Unicode value for the first character of the input expression
UPPER Converts a string to upper-case
ADVERTISEMENT
https://www.w3schools.com/sql/sql_ref_sqlserver.asp 3/13
1/22/25, 5:55 PM SQL Server Functions
SQL Tutorials
Server Math/Numeric
Exercises Certificates Functions
Services Sign Up Log in
HTML
CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C C++ C# BOOTSTRAP R
Function Description
ABS Returns the absolute value of a number
ACOS Returns the arc cosine of a number
ASIN Returns the arc sine of a number
ATAN Returns the arc tangent of a number
ATN2 Returns the arc tangent of two numbers
AVG Returns the average value of an expression
CEILING Returns the smallest integer value that is >= a number
COUNT Returns the number of records returned by a select query
COS Returns the cosine of a number
COT Returns the cotangent of a number
DEGREES Converts a value in radians to degrees
EXP Returns e raised to the power of a specified number
FLOOR Returns the largest integer value that is <= to a number
LOG Returns the natural logarithm of a number, or the logarithm of a number to a specified
base
LOG10 Returns the natural logarithm of a number to base 10
https://www.w3schools.com/sql/sql_ref_sqlserver.asp 4/13
1/22/25, 5:55 PM SQL Server Functions
MAX Tutorials Exercises Returns the maximum value in a set of values
Certificates Services Sign Up Log in
MIN Returns the minimum value in a set of values
HTML
CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C C++ C# BOOTSTRAP R
PI Returns the value of PI
POWER Returns the value of a number raised to the power of another number
RADIANS Converts a degree value into radians
RAND Returns a random number
ROUND Rounds a number to a specified number of decimal places
SIGN Returns the sign of a number
SIN Returns the sine of a number
SQRT Returns the square root of a number
SQUARE Returns the square of a number
SUM Calculates the sum of a set of values
TAN Returns the tangent of a number
SQL Server Date Functions
Function Description
CURRENT_TIMESTAMP Returns the current date and time
https://www.w3schools.com/sql/sql_ref_sqlserver.asp 5/13
1/22/25, 5:55 PM SQL Server Functions
DATEADD
Tutorials Exercises AddsCertificates
a time/date interval to a date and then returns the date
Services Sign Up Log in
DATEDIFF Returns the difference between two dates
HTML
CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C C++ C# BOOTSTRAP R
DATEFROMPARTS Returns a date from the specified parts (year, month, and day values)
DATENAME Returns a specified part of a date (as string)
DATEPART Returns a specified part of a date (as integer)
DAY Returns the day of the month for a specified date
GETDATE Returns the current database system date and time
GETUTCDATE Returns the current database system UTC date and time
ISDATE Checks an expression and returns 1 if it is a valid date, otherwise 0
MONTH Returns the month part for a specified date (a number from 1 to 12)
SYSDATETIME Returns the date and time of the SQL Server
YEAR Returns the year part for a specified date
SQL Server Advanced Functions
Function Description
CAST Converts a value (of any type) into a specified datatype
COALESCE Returns the first non-null value in a list
https://www.w3schools.com/sql/sql_ref_sqlserver.asp 6/13
1/22/25, 5:55 PM SQL Server Functions
CONVERT
Tutorials Exercises Converts a value (of any type) into a specified datatype
Certificates Services Sign Up Log in
CURRENT_USER Returns the name of the current user in the SQL Server database
HTML
CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C C++ C# BOOTSTRAP R
IIF Returns a value if a condition is TRUE, or another value if a condition is FALSE
ISNULL Return a specified value if the expression is NULL, otherwise return the expression
ISNUMERIC Tests whether an expression is numeric
NULLIF Returns NULL if two expressions are equal
SESSION_USER Returns the name of the current user in the SQL Server database
SESSIONPROPERTY Returns the session settings for a specified option
SYSTEM_USER Returns the login name for the current user
USER_NAME Returns the database user name based on the specified id
❮ Previous Next ❯
Track your progress - it's free! Sign Up Log in
ADVERTISEMENT
https://www.w3schools.com/sql/sql_ref_sqlserver.asp 7/13
1/22/25, 5:55 PM SQL Server Functions
Tutorials Exercises Certificates Services Sign Up Log in
HTML
CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C C++ C# BOOTSTRAP R
https://www.w3schools.com/sql/sql_ref_sqlserver.asp 8/13
1/22/25, 5:55 PM SQL Server Functions
Tutorials Exercises Certificates Services Sign Up Log in
HTML
CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C C++ C# BOOTSTRAP R
COLOR PICKER
ADVERTISEMENT
https://www.w3schools.com/sql/sql_ref_sqlserver.asp 9/13
1/22/25, 5:55 PM SQL Server Functions
Tutorials Exercises Certificates Services Sign Up Log in
HTML
CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C C++ C# BOOTSTRAP R
ADVERTISEMENT
https://www.w3schools.com/sql/sql_ref_sqlserver.asp 10/13
1/22/25, 5:55 PM SQL Server Functions
Tutorials Exercises Certificates Services Sign Up Log in
HTML
CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C C++ C# BOOTSTRAP R
ADVERTISEMENT
PLUS SPACES GET CERTIFIED FOR TEACHERS
FOR BUSINESS CONTACT US
Top Tutorials Top References
HTML Tutorial HTML Reference
CSS Tutorial CSS Reference
https://www.w3schools.com/sql/sql_ref_sqlserver.asp 11/13
1/22/25, 5:55 PM SQL Server Functions
JavaScript Tutorial JavaScript Reference
Tutorials How
To Tutorial
Exercises
SQL Tutorial
Certificates SQL Reference
Services
Python Reference
Sign Up Log in
Python Tutorial W3.CSS Reference
HTML
CSS W3.CSS Tutorial
JAVASCRIPT SQL PYTHON BootstrapPHP
JAVA Reference HOW TO W3.CSS C C++ C# BOOTSTRAP R
Bootstrap Tutorial PHP Reference
PHP Tutorial HTML Colors
Java Tutorial Java Reference
C++ Tutorial Angular Reference
jQuery Tutorial jQuery Reference
Top Examples Get Certified
HTML Examples HTML Certificate
CSS Examples CSS Certificate
JavaScript Examples JavaScript Certificate
How To Examples Front End Certificate
SQL Examples SQL Certificate
Python Examples Python Certificate
W3.CSS Examples PHP Certificate
Bootstrap Examples jQuery Certificate
PHP Examples Java Certificate
Java Examples C++ Certificate
XML Examples C# Certificate
jQuery Examples XML Certificate
FORUM ABOUT ACADEMY
W3Schools is optimized for learning and training. Examples might be simplified to improve reading and learning.
Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness
of all content. While using W3Schools, you agree to have read and accepted our terms of use, cookie and privacy
policy.
https://www.w3schools.com/sql/sql_ref_sqlserver.asp 12/13
1/22/25, 5:55 PM SQL Server Functions
Copyright 1999-2025 by Refsnes Data. All Rights Reserved. W3Schools is Powered by W3.CSS.
Tutorials Exercises Certificates Services Sign Up Log in
HTML
CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C C++ C# BOOTSTRAP R
https://www.w3schools.com/sql/sql_ref_sqlserver.asp 13/13