Sort functions of SQL string segmentation

Source: Internet
Author: User
1. Split the string by the specified symbol and return the number of elements after the split (the method is very simple, that is, to check the number of separators in the string, and then add one, which is the required result .) CREATEfunctionGet_StrArrayLength (10) -- separator) (rtrim (@ str) (@ split, @ str) (@ split, @ str ,@

1. Split the string by the specified symbol and return the number of elements after the split (the method is very simple, that is, to check the number of separators in the string, and then add one, which is the required result .) CREATE function Get_StrArrayLength (10) -- delimiter number) (rtrim (@ str) (@ split, @ str) (@ split, @ str ,@

1. Split the string by the specified symbol, the U.S. server, and website space. The number of elements after the split is returned. (The method is very simple. The Hong Kong server is to check the number of separators in the string, and then add one, that is, the result of the request .) CREATE function Get_StrArrayLength (10) -- delimiter number) (rtrim (@ str) (@ split, @ str) (@ split, @ str, @ start) [Call example:,) Return Value: 4] 2. Split the string by the specified symbol and return the elements of the specified index after the split. CREATE function Get_StrArrayStrOfIndex () is as convenient as an array (() returns varchar (1024) (rtrim (@ str) (@ split, @ str) (@ split, @ str, @ start) () end
[Call example:, 2) Return Value: 9] 3. combine the two functions above to traverse the element (50) dbo in the string like an array. get_StrArrayLength (), @ next) Call result:

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.