SQL string functions (1/3)

Source: Internet
Author: User
SQL string functions, including many operations such as space-removing functions to retrieve substrings, function strings, comparison functions, string operations, function data type conversion functions, date functions, and so on.

SQL string functions, including many operations such as space-removing functions to retrieve substrings, function strings, comparison functions, string operations, function data type conversion functions, date functions, and so on.

SQL string functions, including many functions such as space-removing functions, getting substrings, function strings, comparison functions, string operations functions, data type conversion functions, date functions
And so on.

Space-removing Function
1. ltrim () removes spaces in the string header.

2. rtrim () removes spaces at the end of the string.

Iii. substring Functions
1. left ()
Left ( , )
Returns character_expression, which starts from integer_expression at the left.

2. right ()
Right ( , )
Returns character_expression, which is a string of characters starting from integer_expression.

3. substring ()
Substring ( , , Length)
Returns the length of the string starting from the start _ position Character on the left.

Iv. String comparison functions
1. charindex ()
Returns the starting position of a specified substring in a string.
Charindex (<'substring _ expression'>, )
Here, substring _ expression is the character expression to be searched, and expression can be a string or a column name expression. If no substring is found, the return value is 0.
This function cannot be used for text and image data types.
2. patindex ()
Returns the starting position of a specified substring in a string.
Patindex (<'% substring _ expression %'>, ) The neutron string expression must have the percent sign "%" before and after it; otherwise, the return value is 0.
Unlike the charindex function, wildcards can be used in the child strings of the patindex function, which can be used for char, varchar, and text data types.

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.