String function
Length and analysis
DATALENGTH (CHAR_EXPR) Returns the character string contains the number of characters, but does not contain spaces behind
Substring (Expression, Start, Length) not to say, tap
Right (char_expr, int_expr) Returns the right INT_EXPR character
Character operation class
Upper (char_expr) to uppercase
Lower (char_expr) to lowercase
Space (int_expr) Generates INT_EXPR
Replicate (CHAR_EXPR, INT_EXPR) Copy String INT_EXPR
Reverse (char_expr) reversing strings
Stuff (char_expr1, start, length, char_expr2) from the string char_expr1
LENGTH characters starting with Start with char_expr2 instead
LTRIM (char_expr) RTRIM (char_expr) Remove space
ASCII (ASCII) two functions corresponds to the ASCII code, according to ASCII?
String lookup
Charindex (CHAR_EXPR, Expression) Returns the starting position of char_expr
Patindex ("% Pattern%", Expression) Returns the starting position of the specified mode, otherwise 0
2. Mathematical functions
ABS (numeric_expr) seeking absolute value
CEILING (Numeric_expr) takes greater than or equal to the minimum integer of the specified value
Exp (Float_expr) Take Index
Floor (numeric_expr) is less than or equal to the specified value to be the most integer
Pi () 3.1415926 .........
Power (Numeric_expr, Power) Returns Power
RAND ([INT_EXPR]) Random number generator
Round (numeric_expr, int_expr) An INT_EXPR specified in the full range
Sign (int_expr) Returns 1, 0, -1 according to the positive number, 0, negative number,
SQRT (float_expr) square root
3. Date function
Getdate () return date
Datename (datepart, date_expr) Returns Name, such as June
DatePart (DatePart, Date_EXPR) takes a part
DateDiff (datepart, date_expr1.dateexpr2) date difference
DATEADD (DATEPART, NUMBER, DATE_EXPR) Return date plus Number
Datepart in the above function
Writing value and meaning
YY 1753-9999
QQ 1-4
MM 1-12
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
Date conversion
CONVERT ()
4. System function
SUSER_NAME () User Login Name
User_name () Name in the database
User user name in the database
SHOW_ROLE () rules for current users
DB_NAME () Database Name
Object_name (obj_id) Database Object Name
Col_name (obj_id, col_id) column name
Col_length (ObjName, Colname) Length Length
Valid_name (char_expr) is a valid identifier