SQL Server Function Summary

Source: Internet
Author: User
Tags in degrees mathematical functions natural logarithm value of pi

Aggregate functions

AVG (numeric_expr) returns integer, decimal, money, float --- returns the average value of each value in the group
Count (* | column_name | distinct column_name) returns integer --- number of records in the returned table | returns the number of specified columns | returns the number of different values of the specified Column
Count_big (* | column_name | distinct column_name) returns bigint --- returns the number of records in the table | returns the number of specified columns | returns the number of different values of the specified Column
Max (Express) --- returns the maximum value of the expression
Min (Express) --- returns the minimum value of the expression
Sum (Express) returns integer, decimal, money, float --- returns the sum of all values in the expression or the sum of only non-repeating values
VaR (Express) returns float --- returns the variance of all values in the given expression

Date and Time Functions

Current_timestamp --- returns the current date and time
Dateadd (datepart, number, date_expr) --- return date plus number
Datepart (writing, value, meaning)
YY 1753-March
QQ: 1-4
Mm 1-March December
Dy 1-366
DD 1-31
WK 1-54 weeks
DW 1-7 weeks
HH 0-23 hours
Mi 0-59 minutes
SS 0-59 seconds
MS 0-999 Ms
Datediff (date part <varchar>, start date <datetime>, end date <datetime>) returns datetime --- returns the number of dates and time boundaries across two specified dates
Datename (date part <varchar>, expression <datetime>) returns varchar --- returns a string that represents the specified date part of a specified date
Datepart (date part <varchar>, expression <datetime>) returns integer --- returns an integer that represents the specified date part of the specified date
Day (expression <datetime>) returns integer --- returns the integer that represents the "day" part of the specified date
Getdate () returns datetime --- returns the current system date and time
Getutcdate () returns datetime --- returns the datetime value representing the current UTC time
Isdate (expression <varchar>) returns integer --- determines whether the input expression is a valid date
Month (expression <datetime>) returns integer --- returns the integer representing the "month" part of the specified date
Sysdatetime () returns datetime (7) --- returns the current database system timestamp as the datetime (7) Value
Sysdatetimeoffset () returns datetimeoffset --- returns the current database system timestamp as the datetimeoffset value, which retains the database Time Zone offset
Sysutcdatetime () returns datetime2 (7) --- returns the current database system timestamp (UTC) as the datetime2 (7) Value
Year (expression <datetime>) returns integer --- returns an integer representing the "year" part of the specified date

Mathematical functions

ABS (Express) --- returns the absolute value
ACOs (radian expression <float>) returns float --- returns the angle in radians, and its cosine is a given floating point expression.
Asin (radian expression <float>) returns float --- returns the angle in radians, and its sine is a given floating point expression.
ATIM (radian expression <float>) returns float --- returns the angle in radians, and its positive tangent is the given floating point expression.
Ceiling (expression <exact number or approximate number>) --- returns the smallest integer greater than or equal to the given value expression
Cos (radian expression <float>) returns float --- returns the triangular cosine of the given angle
Cot (radian expression <float>) returns float --- returns the triangle cotangent to the specified angle
Degrees (expression <exact number or approximate number>) --- if the angle is expressed in radians, the corresponding angle expressed in degrees is returned.
Exp (radian expression <float>) returns float --- returns the exponent value of the given floating point expression
Floor (expression <exact number or approximate number>) --- returns the maximum integer less than or equal to the given value expression
Log (radian expression <float>) returns float --- returns the natural logarithm of the given floating-point expression
Log10 (radian expression <float>) returns float --- returns the common logarithm of the given floating-point expression (base-10 logarithm)
Pi () returns float --- returns the constant value of Pi
Power (expression <precise number or approximate number>, power <precise number or approximate number>) --- returns the value of the specified power of a given expression
Radians (degree expression <exact number or approximate number>) --- returns the radians of the corresponding degree expression
Rand (<optional> seed value <integer>) returns float --- returns a random floating point number from 0 to 1
Round (expression <exact number or approximate number>, precision <integer>, <optional> function <integer>) --- returns a value expression, rounded to the specified length or precision
Sign (expression <exact number or approximate number>) --- returns the positive (+ 1), zero (0), or negative (-1) of the given expression)
Sin (radian expression <float>) returns float --- returns the triangular sine of the given angle
SQRT (expression <float>) returns float --- returns the square root of the given expression
Square (expression <float>) returns float --- returns the square of the given expression
Sin (radian expression <float>) returns float --- returns the tangent of the expression

Other functions

Cast (expression as data type) --- convert one data type to another by expression
Coalesce (<unlimited number of parameters> Expression) --- return the first non-null expression in the Parameter
Convert (data type, expression, <optional> date format <smallint>) --- convert one data type to another
Style ID style format
100 or 0 mon dd yyyy hh: miam
101/DD/yy
102 yy. Mm. dd
103 dd/mm/yy
104 dd. mm. yy
105 DD-mm-yy
106 dd mon YY
107 mod DD, YY
108 hh: mm: SS
109 or 9 Mon dd yyyy hh: MI: SS: mmmam
110-dd-yy
111 YY/MM/dd
112 yyyymmdd
113 or 3 dd mon yyyy hh: mm: SS: Mmm (24 h)
114 hh: MI: SS: Mmm (24 h)
120 or 20 yyyy-mm-dd hh: MI: SS (24 h)
121 or 21 yyyy-mm-dd hh: MI: Ss. Mmm (24 h)
126 yyyy-mm-ddthh: mm: SS: Mmm
130 dd mon yyyy hh: MI: SS: mmmam
131 dd/mm/yy hh: MI: SS: mmmam
Datalength (expression) --- returns the number of bytes used to represent the expression
Ident_current (Table Name) --- returns the final id value generated for any session and a specific table in any scope
@ Identity --- return the last generated id value for any table in all scopes of the current session
Isnull (check expression, replace value) --- replace null with the specified replace value
Isnumeric (expression) --- determines whether the expression is a valid value type
Newid () returns uniqueidentifier --- unique value of the uniqueidentifier type
Nullif (expression, expression) if the two are not equivalent, the first expression is returned; otherwise, the return value is null-if the two expressions are equivalent, the return value is null.
@ Rowcount --- returns the number of rows affected by the previous statement.
Rowcount_big () --- returns the number of rows affected by the execution of the previous statement.
Scope_identity () --- returns the last identity value inserted into the same range of identity columns.

String Functions

ASCII (expression) returns integer --- returns the ASCII of the leftmost character in the character expressionCodeValue
Char (tinyint) returns char (1) --- converts an integer ASCII code to a character
Charindex (search expression, expression to be searched, start position) returns integer --- returns the start position of the specified expression in the string
Left (expression <varchar | nvarchar>, number of characters <integer>) --- returns the leftmost specified number of characters in the character expression
Len (expression <varchar | nvarchar>) returns integer --- returns the number of characters in the given string expression
Lower (expression <varchar | nvarchar>) --- returns a character expression that converts uppercase to lowercase.
Ltrim (expression <varchar | nvarchar>) --- returns the character expression after the leading space is deleted.
Nchar (expression <integer>) --- returns Unicode characters with the given integer code
Patindex (search mode text <varchar | nvarchar>, expression to search <varchar | nvarchar>) returns integer --- returns the starting position of the first occurrence of the pattern in the specified expression
Quotename (expression <nvarchar (128)>, <optional> Bootstrap character <char (1)>) returns nvarchar --- returns a unicode string that is added as a valid sqlserver separator identifier
Replace (expression to be searched <varchar | nvarchar>, search expression <varchar | nvarchar>, and replace expression <varchar | nvarchar>) --- replace all the second expressions in the first expression with the third expression
Replicate (expression <varchar | nvarchar>, expression <bigint>) --- repeat character expression by specified number of times
Reverse (expression <varchar | nvarchar>) --- returns the reverse expression of the Character Expression
Right (expression <varchar | nvarchar>, expression <bigint>) --- return the number of characters specified on the right of the Character Expression
Rtrim (expression <varchar | nvarchar>) --- returns the character expression after all trailing spaces are truncated.
Space (expression <integer>) returns char --- returns a string consisting of repeated Spaces
STR (expression <float>, <optional> length <integer>, <optional> decimal places <integer>) returns char --- returns the character expression converted from the numeric expression
Stuff (expression to be searched, start position, number of characters, replacement expression) --- delete a character of the specified length and insert another character group at the specified start point
Substring (expression, start position, length) --- return part of the Character Expression
Unicode (expression) --- returns the Unicode integer of the first character of the expression.
Upper (expression <varchar | nvarchar>) --- returns a character expression that converts lowercase letters to uppercase letters.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.