码迷,mamicode.com
首页 > 其他好文 > 详细

实现字符串分隔功能的函数

时间:2017-05-31 12:07:23      阅读:146      评论:0      收藏:0      [点我收藏+]

标签:begin   ring   str   功能   sep   set   tor   insert   cti   

CREATE FUNCTION [dbo].[Func_Split]
(  
   @inputstr VARCHAR(max), 
   @seprator VARCHAR(10)
)
RETURNS @temp TABLE (A VARCHAR(200))
AS
BEGIN
DECLARE @i INT
SET @inputstr = RTRIM(LTRIM(@inputstr))
SET @i = CHARINDEX(@seprator , @inputstr)
WHILE @i >= 1
BEGIN
INSERT @temp VALUES(LEFT(@inputstr , @i - 1))
SET @inputstr = SUBSTRING(@inputstr , @i + 1 , LEN(@inputstr) - @i)
SET @i = CHARINDEX(@seprator , @inputstr)
END
IF @inputstr <> \
INSERT @temp VALUES(@inputstr)
RETURN 
END

 

实现字符串分隔功能的函数

标签:begin   ring   str   功能   sep   set   tor   insert   cti   

原文地址:http://www.cnblogs.com/blossomwei/p/6923018.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!