1 CREATE FUNCTION [dbo].[L_SplitStr_Thirteen] 2 ( 3 @SourceSql1 VARCHAR(8000), 4 @SourceSql2 VARCHAR(8000), 5 @SourceSql3 VARCHAR(8000), 6 @SourceSql4 VARCHAR(8000), 7 @SourceSql5 VARCHAR(8000), 8 @SourceSql6 VARCHAR(8000), 9 @SourceSql7 VARCHAR(8000), 10 @SourceSql8 VARCHAR(8000), 11 @SourceSql9 VARCHAR(8000), 12 @SourceSql10 VARCHAR(8000), 13 @SourceSql11 VARCHAR(8000), 14 @SourceSql12 VARCHAR(8000), 15 @SourceSql13 VARCHAR(8000), 16 @StrSeprate CHAR(1) 17 ) 18 RETURNS @temp TABLE(str1 VARCHAR(200),str2 VARCHAR(200),str3 VARCHAR(200),str4 VARCHAR(200),str5 VARCHAR(200),str6 VARCHAR(200),str7 VARCHAR(200),str8 VARCHAR(200),str9 VARCHAR(200),str10 VARCHAR(200),str11 VARCHAR(200),str12 VARCHAR(200),str13 VARCHAR(200)) 19 AS 20 BEGIN 21 declare @str1 varchar(200) 22 declare @str2 varchar(200) 23 declare @str3 varchar(200) 24 declare @str4 varchar(200) 25 declare @str5 varchar(200) 26 declare @str6 varchar(200) 27 declare @str7 varchar(200) 28 declare @str8 varchar(200) 29 declare @str9 varchar(200) 30 declare @str10 varchar(200) 31 declare @str11 varchar(200) 32 DECLARE @str12 VARCHAR(200) 33 DECLARE @str13 VARCHAR(200) 34 35 WHILE(@SourceSql1 <> '') 36 BEGIN 37 SET @str1=LEFT(@SourceSql1,CHARINDEX(@StrSeprate,@SourceSql1,1)-1) 38 SET @SourceSql1=STUFF(@SourceSql1,1,CHARINDEX(@StrSeprate,@SourceSql1,1),'') 39 40 SET @str2=LEFT(@SourceSql2,CHARINDEX(@StrSeprate,@SourceSql2,1)-1) 41 SET @SourceSql2=STUFF(@SourceSql2,1,CHARINDEX(@StrSeprate,@SourceSql2,1),'') 42 43 SET @str3=LEFT(@SourceSql3,CHARINDEX(@StrSeprate,@SourceSql3,1)-1) 44 SET @SourceSql3=STUFF(@SourceSql3,1,CHARINDEX(@StrSeprate,@SourceSql3,1),'') 45 46 SET @str4=LEFT(@SourceSql4,CHARINDEX(@StrSeprate,@SourceSql4,1)-1) 47 SET @SourceSql4=STUFF(@SourceSql4,1,CHARINDEX(@StrSeprate,@SourceSql4,1),'') 48 49 SET @str5=LEFT(@SourceSql5,CHARINDEX(@StrSeprate,@SourceSql5,1)-1) 50 SET @SourceSql5=STUFF(@SourceSql5,1,CHARINDEX(@StrSeprate,@SourceSql5,1),'') 51 52 SET @str6=LEFT(@SourceSql6,CHARINDEX(@StrSeprate,@SourceSql6,1)-1) 53 SET @SourceSql6=STUFF(@SourceSql6,1,CHARINDEX(@StrSeprate,@SourceSql6,1),'') 54 55 SET @str7=LEFT(@SourceSql7,CHARINDEX(@StrSeprate,@SourceSql7,1)-1) 56 SET @SourceSql7=STUFF(@SourceSql7,1,CHARINDEX(@StrSeprate,@SourceSql7,1),'') 57 58 SET @str8=LEFT(@SourceSql8,CHARINDEX(@StrSeprate,@SourceSql8,1)-1) 59 SET @SourceSql8=STUFF(@SourceSql8,1,CHARINDEX(@StrSeprate,@SourceSql8,1),'') 60 61 SET @str9=LEFT(@SourceSql9,CHARINDEX(@StrSeprate,@SourceSql9,1)-1) 62 SET @SourceSql9=STUFF(@SourceSql9,1,CHARINDEX(@StrSeprate,@SourceSql9,1),'') 63 64 SET @str10=LEFT(@SourceSql10,CHARINDEX(@StrSeprate,@SourceSql10,1)-1) 65 SET @SourceSql10=STUFF(@SourceSql10,1,CHARINDEX(@StrSeprate,@SourceSql10,1),'') 66 67 SET @str11=LEFT(@SourceSql11,CHARINDEX(@StrSeprate,@SourceSql11,1)-1) 68 SET @SourceSql11=STUFF(@SourceSql11,1,CHARINDEX(@StrSeprate,@SourceSql11,1),'') 69 70 SET @str12=LEFT(@SourceSql12,CHARINDEX(@StrSeprate,@SourceSql12,1)-1) 71 SET @SourceSql12=STUFF(@SourceSql12,1,CHARINDEX(@StrSeprate,@SourceSql12,1),'') 72 73 SET @str13=LEFT(@SourceSql13,CHARINDEX(@StrSeprate,@SourceSql13,1)-1) 74 SET @SourceSql13=STUFF(@SourceSql13,1,CHARINDEX(@StrSeprate,@SourceSql13,1),'') 75 76 INSERT @temp VALUES(@str1,@str2,@str3,@str4,@str5,@str6,@str7,@str8,@str9,@str10,@str11,@str12,@str13) 77 END 78 RETURN 79 END 80 GO 81 82
sql函数-表值函数,用于批量操作数据
猜你喜欢
转载自www.cnblogs.com/JvYouQing/p/10290708.html
今日推荐
周排行