Commonly used string functions in SQL Server

Source: Internet
Author: User

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



Reference: Common functions in SQL Server http://www.studyofnet.com/news/1007.html


Commonly used string functions in SQL Server

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.