1 CREATE FUNCTION FN_GetFormat_String
2 (
3 @Format NVARCHAR(10),
4 @String VARCHAR(8000)
5 )
6 RETURNS @TEMP TABLE(iRow INT IDENTITY(1,1),vReturn VARCHAR(1000))
7 AS
8 BEGIN
9 /*
10 CREATE TIME:2009-07-17 15:23
11 BY:
12 说明:根据分隔参数[@Format],将[@String]以参数分隔开,返回表
13 */
14 DECLARE @I INT
15 SET @I=CHARINDEX(@Format,@String)
16
17 WHILE @I >0
18 BEGIN
19 INSERT INTO @TEMP(vReturn) SELECT SUBSTRING(@String,1,@I-1)
20 SET @String=SUBSTRING(@String,@I+1,LEN(@String))
21 SET @I=CHARINDEX(@Format,@String)
22 END
23 IF LEN(@String) >0 INSERT INTO @TEMP(vReturn) SELECT @String
24 RETURN
25 END
2 (
3 @Format NVARCHAR(10),
4 @String VARCHAR(8000)
5 )
6 RETURNS @TEMP TABLE(iRow INT IDENTITY(1,1),vReturn VARCHAR(1000))
7 AS
8 BEGIN
9 /*
10 CREATE TIME:2009-07-17 15:23
11 BY:
12 说明:根据分隔参数[@Format],将[@String]以参数分隔开,返回表
13 */
14 DECLARE @I INT
15 SET @I=CHARINDEX(@Format,@String)
16
17 WHILE @I >0
18 BEGIN
19 INSERT INTO @TEMP(vReturn) SELECT SUBSTRING(@String,1,@I-1)
20 SET @String=SUBSTRING(@String,@I+1,LEN(@String))
21 SET @I=CHARINDEX(@Format,@String)
22 END
23 IF LEN(@String) >0 INSERT INTO @TEMP(vReturn) SELECT @String
24 RETURN
25 END