呵呵,没有什么特别的含义。其实这个函数本身就有问题,只是提醒自己关于字符串操作的另外一种写法。
1 ALTER FUNCTION FN_GetTable_FromFormatString(@Format NVARCHAR(10),@String VARCHAR(8000))
2 RETURNS @TEMP TABLE(iRow INT IDENTITY(1,1),vReturn VARCHAR(1000))
3 AS
4 BEGIN
5 /*
6 CREATE TIME:2010-01-14 17:14
7 BY:王召冠
8 说明:根据分隔参数[@Format],将[@String]以参数分隔开,返回表
9 */
10 DECLARE @t1 TABLE(id INT IDENTITY, btEmpty BIT)
11 DECLARE @t2 TABLE(WORK VARCHAR(8000))
12
13 INSERT INTO @t1
14 SELECT TOP (LEN(@String)) NULL --仅支持2005及更改版本
15 FROM sysobjects, syscolumns
16
17 INSERT INTO @t2 ([WORK]) VALUES ( @String )
18
19 INSERT INTO @TEMP(vReturn)
20 SELECT SUBSTRING(A.Work, B.id, CHARINDEX(@Format, A.Work + @Format, B.id) - B.id)
21 FROM @t2 A,
22 @t1 B
23 WHERE SUBSTRING(@Format + A.Work, B.id, 1) = @Format
24
25 RETURN
26 END
27
2 RETURNS @TEMP TABLE(iRow INT IDENTITY(1,1),vReturn VARCHAR(1000))
3 AS
4 BEGIN
5 /*
6 CREATE TIME:2010-01-14 17:14
7 BY:王召冠
8 说明:根据分隔参数[@Format],将[@String]以参数分隔开,返回表
9 */
10 DECLARE @t1 TABLE(id INT IDENTITY, btEmpty BIT)
11 DECLARE @t2 TABLE(WORK VARCHAR(8000))
12
13 INSERT INTO @t1
14 SELECT TOP (LEN(@String)) NULL --仅支持2005及更改版本
15 FROM sysobjects, syscolumns
16
17 INSERT INTO @t2 ([WORK]) VALUES ( @String )
18
19 INSERT INTO @TEMP(vReturn)
20 SELECT SUBSTRING(A.Work, B.id, CHARINDEX(@Format, A.Work + @Format, B.id) - B.id)
21 FROM @t2 A,
22 @t1 B
23 WHERE SUBSTRING(@Format + A.Work, B.id, 1) = @Format
24
25 RETURN
26 END
27