SQL Server written in the same industry is similar to the split function.

Source: Internet
Author: User

Create Function f_split (@ sourcesql varchar (8000), @ strseprate varchar (10 ))
Returns @ temp table (A varchar (100 ))
-- Implement the split Function
-- Date: 2005-4-20
-- Author: Domino
As
Begin
Declare @ I int
Set @ sourcesql = rtrim (ltrim (@ sourcesql ))
Set @ I = charindex (@ strseprate, @ sourcesql)
While @ I> = 1
Begin
Insert @ temp values (left (@ sourcesql, @ i-1 ))
Set @ sourcesql = substring (@ sourcesql, @ I + 1, Len (@ sourcesql)-@ I)
Set @ I = charindex (@ strseprate, @ sourcesql)
End
If @ sourcesql <> '\'
Insert @ temp values (@ sourcesql)
Return
End

Usage: Select * From DBO. f_split ('a: B: C: D: e ',':')

http://blog.csdn.net/great_domino/archive/2005/04/20/355033.aspx

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.