SQL Functions

---- ---- arithmetic functions

/ Trigonometric *** *** /
the SIN (float_expression) - Returns the sine of the angle in radians
COS (float_expression) - Returns the cosine of the angle expressed in radians
TAN (float_expression) - Returns the angle in radians tangent
cOT (float_expression) - returns the cotangent of the angle in radians
/ inverse trigonometric function *** *** /
ASIN (float_expression) - returns the sine of the angle in radians is FLOAT value
ACOS (float_expression) - - returns the cosine of an angle FLOAT is expressed in radians
ATAN (float_expression) - returns the tangent of an angle is FLOAT expressed in radians
ATAN2 (float_expression1, float_expression2)
- returns the tangent is float_expression1 / float_expression2 in radians angle of
the DEGREES (numeric_expression)
- radians to degrees to return the same data type as the expression may
--INTEGER / MONEY / REAL / FLOAT type
rADIANS (numeric_expression) - the degrees to radians expression returns the same data types of
--INTEGER / MONEY / REAL / FLOAT type
EXP (float_expression) - returns the index value of the expression
LOG (float_expression) - Returns the natural logarithm of the expression
LOG10 (float_expression) - Returns the expression in the base 10 logarithm
SQRT (float_expression) - returns the square root of the expression
/ function approximating *** ** * /
CEILING (numeric_expression) - returns> = the smallest integer data type of the expression is the same expression can be returned
--INTEGER / MONEY / REAL / FLOAT type
smallest integer returns <= expression - FLOOR (numeric_expression) returns the data type of the expression may be the same
--INTEGER / MONEY / REAL / FLOAT type
ROUND (numeric_expression) - returns the data precision integer_expression is rounded value returned
- the same type of expression can be INTEGER / MONEY / REAL / FLOAT type
ABS (numeric_expression) - returns the data type and returns the absolute value of the expression is the same expression can be
--INTEGER / MONEY / REAL / FLOAT type
sIGN (numeric_expression) - returns the sign test parameters 0 type 1 data value of zero or a positive number of negative number -1
- may be the same as the expression INTEGER / MONEY / REAL / FLOAT type
the PI () - returns a value of π i.e. 3.1415926535897936
RAND ([integer_expression]) - with an optional [integer_expression] for seed the random floating point worth between 0-1


---- ---- string function
ASCII () - function returns a character expression leftmost character ASCII value
CHAR () - function is used to convert the ASCII characters
- if no input 0-255 ASCII value between CHAR function returns a NULL value
LOWER () - function to all lowercase string
UPPER () - function to all uppercase string
STR () - function to convert numerical data for the character data
LTRIM () - function to the string head space removed
RTRIM () - function of the string trailing spaces removed
LEFT (), RIGHT (), SUBSTRING () - function returns the string portion
CHARINDEX (), PATINDEX () - function returns the substring of a string specified start position appearing
SOUNDEX () - function returns a four character code
--SOUNDEX similar function may be used to find the string sound but SOUNDEX function are digital characters and only return a value of 0
dIFFERENCE () - function returns the value of the difference of two expressions of characters returned by the function SOUNDEX
--0 first two character SOUNDEX function returns a value different from
--1 two SOUNDEX function returns the same value of the first character
--2 two functions SOUNDEX Like the first two characters of the return value
--3 same Twenty-three characters SOUNDEX function returns two values
--4 SOUNDEX function returns two identical


QUOTENAME () - function returns a character string is enclosed particular up
/ * select quotename ( 'abc' , '{') quotename ( 'abc')
results are as follows
------------- {---------------------
{ABC} [ABC] * /

REPLICATE () - function returns a character string repetition number of times specified character_expression
/ * select replicate ( 'abc' , 3) replicate ( 'abc', -2)
results are as follows
------------- ----------
ABCABCABC NULL * /

REVERSE () - function to the character string specified in the order reversed
REPLACE () - function returns a character string is replaced by the specified substring
/ * select replace ( 'abc123g' , '123', 'def')
running The results are as follows
----------- -----------
ABCDEFG * /

SPACE () - function returns an empty string length specified
STUFF () - function string replaced by another sub-substring string length specified position


Data type conversion functions ---- ----
the CAST () function syntax follows
the CAST () (<expression The> the AS <DATA_ type> [length])
the CONVERT () function has the following syntax
CONVERT () (<data_ type> [length ], <expression> [, style ])

select cast (100 + 99 as char ) convert (varchar (12), getdate ())
results are as follows
--------------------------- ------------ ---
199 15 Jan 2000

Date function ---- ----
DAY () - function returns the date date_expression the value
MONTH () - Returns the month date_expression function in the
YEAR () - function returns date_expression the year value
DATEADD (<datepart >, <number>, <date>)
- function returns the date date date specified interval plus an additional number generated new date
the DATEDIFF (<the datepart>, <number>, <date>)
- function returns two specified date except in terms datepart
DATENAME (<datepart>, <date >) - function returns a string portion of the date specified
DATEPART (<datepart>, <date >) - function returns an integer value in the form of the date specified portion
GETDATE () - function returns the current date and time to the system default format DATETIME

---- ---- system function
APP_NAME () - function returns the currently executing application name
COALESCE () - function returns the first non-NULL expression value of a number of expression
COL_LENGTH (< 'table_name' >, < 'column_name'>) - function returns the length of the value specified in field
COL_NAME (<table_id>, <column_id >) - function returns the name of the field that is specified in the column name
DATALENGTH () - function returns data the actual length of the data expression
DB_ID ([ 'database_name']) - function returns the ID database
DB_NAME (database_id) - function returns the name of the database
HOST_ID () - function returns the name of the server computer
HOST_NAME () - the function returns the name of the server computer
the IDENTITY (<data_type> [, SEED INCREMENT]) [the AS column_name])
- Identity () function is used only in a SELECT iNTO statement identity column for inserting a column into a new table
/ * select Identity (int,. 1,. 1) aS column_name
INTO NewTable
from oldtable * /
the ISDATE () - function to determine whether a given reasonable expression date
ISNULL (<check_expression>, <replacement_value>) - function NULL value in the expression is replaced with the specified value
ISNUMERIC () - function to determine whether an expression is given to a reasonable value
function returns a value of type UNIQUEIDENTIFIER - () the NEWID
NULLIF (<expression1>, <expression2>)
when --NULLIF function with equal expression2 expression1 returns a NULL value is returned if a value equal expression1

 

Reproduced in: https: //www.cnblogs.com/kevinkim/archive/2010/01/11/1643901.html

Guess you like

Origin blog.csdn.net/weixin_34279184/article/details/94493048