Get the App
SLTechnology News&Howtos  ›  Development  › 

What are the string functions in SQLServer

Shulou Source: shulou.com Published: 2022-06-01 02:56:10 09月11日 Update

This article is to share with you about what string functions are in SQLServer. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

String function

Len () calculates the length of the string

Select LEN (name) from test1-calculates the length of the name

Case conversion lower () upper ()

Select lower ('STUDENT!') select upper ('student!')

Remove the space on the left side of the empty ltrim () string and the space on the right side of the rtrim () string

Declare @ str varchar ='an an a 'select ltrim (@ str) select rtrim (@ str)

String interception substring () left () right ()

Select substring ('HelloWorldcast Magazine 6, 6)-select left of any length can be intercepted (5)-select right can be intercepted from the left (HelloWorldwide recording 6)-intercepted from the right

String replacement replace ()

Select replace ('HelloWorldConcepts, replacement, etc.)-string, the string to be replaced, the string to be replaced

Strings drop the order reverse ()

Select reverse ('abc')-- cba

Returns the unpositioned charindex () where string 1 appears in string 2

Charindex (srt1, srt2)-- the start position of srt1 in srt2. The result is: 5-- only the position that appears for the first time can be checked, and no match returns 0.

The specified number of repeats string value replicate ()

The result of select replicate ('abc',4) is: abcabcabcabc, thank you for reading! This is the end of this article on "what are the string functions in SQLServer?". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!

Tags: Characters strings functions position length content more spaces articles results good practical right size articles times see knowledge first time order Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MySQL MariaDB vpn NVidia Shulou Technology