SQL Create field information (table-valued function)

Source: Internet
Author: User

1 ALTER FUNCTION [dbo].[fnt_splitstring]2 (3     @p1 varchar(Max),4     @p3 varchar(255)5 )6 RETURNS 7 @Table_Var TABLE 8 (9C1varchar(Max)Ten ) One  as A BEGIN -     Declare @p2 varchar(Max) -     Set @p2=RTrim(LTrim(@p1)) the     Declare @pos1 int -     Declare @pos2 int -     Set @pos1=1 -     Set @pos2=1 +      while(@pos1<Len(@p2)) -     begin +         Set @pos1=charindex(@p3,@p2) A         if(@pos1=0) at         begin -             Insert  into @table_var Values(@p2) -             Set @pos1=Len(@p2) -         End -         Else -         begin in             Insert  into @table_var Values( Left(@p2,@pos1-1)) -             Set @p2=right(@p2,Len(@p2)-@pos1) to             Set @pos1=0 +         End -     End the     RETURN  * END $ Panax Notoginseng 'Invocation Mode - Select C1, (Row_number () over (Order by @ @Cursor_Rows)) as C2 from dbo. Fnt_splitstring ('Id,wbs,quantity,mpsno,attribute,filecontent,materielname,materielcode,exportaccount',',')

SQL Create field information (table-valued function)

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.