SQL Server Common functions

Source: Internet
Author: User
Tags lowercase mathematical functions square root

1. String functions:

len (expression) returns the number of characters (not bytes) of the given string expression, with no trailing spaces.

DATALENGTH (char_expr) returns a string that contains the number of characters but does not contain the following spaces
Length (expression,variable) specifies the lengths of the string or variable names.
SUBSTRING (expression,start,length) Not much to say, take a substring
Right (char_expr,int_expr) returns int_expr characters to the left of the string
Concat (STR1,STR2,...) Returns the string from the parameter link.

DATALENGTH (char_expr) returns a string that contains the number of characters but does not contain the following spaces
Length (expression,variable) specifies the lengths of the string or variable names.
SUBSTRING (expression,start,length) Not much to say, take a substring
Right (char_expr,int_expr) returns int_expr characters to the left of the string
Concat (STR1,STR2,...) Returns the string from the parameter link.


Character Manipulation classes:


Upper (char_expr) to uppercase
Lower (char_expr) to lowercase
UCase (String) returns a Variant (string) that contains a string that is converted to uppercase.
LCase (String) returns the lowercase form of the string.
Space (int_expr) generates int_expr spaces
Replicate (char_expr,int_expr) copy string int_expr times
reverse (char_expr) Reverse string
Stuff (CHAR_EXPR1,START,LENGTH,CHAR_EXPR2) replaces the length character in the string char_expr1 from start with a char_expr2
LTrim (char_expr) RTrim (char_expr) Remove spaces
ASCII (char) char (ASCII) two functions correspond, take ASCII code, according to ASCII fetch character


String Lookup:


CHARINDEX (char_expr,expression) returns the starting position of the char_expr
Patindex ("%pattern%", expression) returns the starting position of the specified pattern, otherwise 0
Locate (Substr,str,pos) returns a substring substr where the first occurrence of the string str occurs


2. Mathematical functions


ABS (NUMERIC_EXPR) Seek absolute value
Ceiling (numeric_expr) takes the smallest integer greater than or equal to the specified value
exp (float_expr) fetch index
Floor (numeric_expr) is less than or equal to the specified worth maximum integer
Power (Numeric_expr,power) back to power sub-party
rand ([int_expr]) random number generator
round (numeric_expr,int_expr) Ann int_expr Specifies the accuracy of rounding
Sign (INT_EXPR) based on positive, 0, negative, return +1,0,-1
sqrt (float_expr) square root
exp (float x): x power of E
Tan (float x): Calculates the tangent of X (radians).
Atan (float x): Find the inverse tangent of x (radians)
cos (float x): Calculate the cosine of x (radians)
ACOs (float x): Find the inverse cosine of x (radians)
sin (float x): Calculates the sinusoidal value of x (radians).
Asin (FLOAT x): The inverse sine value of x (radians)
fabs (float x): The absolute value of the floating-point number x
Fmod (float x, float y): Calculates the remainder of X/y
Pow (float x, float y): Calculates the y power of X.
sqrt (float x): Calculates the square root of x.


3. Date, Time function


GETDATE () Return date
Datename (datepart,date_expr) return name
DATEPART (datepart,date_expr) take a date part
DateDiff (DATEPART,DATE_EXPR1.DATEEXPR2) Date Difference
DATEADD (datepart,number,date_expr) return date plus number


4. System functions


Suser _name () User logon name
user_name () The user's name in the database
user user's name in the database
db_name () database name
col_name (obj_id,col_id Column name
col_length (Objname,colname) Column length
valid_name (char_expr) is a valid identifier

SQL Server common functions (GO)

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.