DECLARE @CIndex smallint;
DECLARE @InputString VARCHAR(1000);
DECLARE @Split1 VARCHAR(1000);
SET @InputString= '1025,1033,1014,'
SET @CIndex=CHARINDEX(',',@InputString)
WHILE NOT(@CIndex = 0)
BEGIN
SET @Split1=RTRIM(LTRIM(LEFT(@InputString, @CIndex - 1)))
--取出前一段字串後剩餘的字串
SET @InputString = RIGHT(@InputString, LEN(@InputString) - @CIndex)
SET @CIndex=CHARINDEX(',',@InputString)
END
參考連結
http://mydiamond.pixnet.net/blog/post/22415645-sql-split
DECLARE @InputString VARCHAR(1000);
DECLARE @Split1 VARCHAR(1000);
SET @InputString= '1025,1033,1014,'
SET @CIndex=CHARINDEX(',',@InputString)
WHILE NOT(@CIndex = 0)
BEGIN
SET @Split1=RTRIM(LTRIM(LEFT(@InputString, @CIndex - 1)))
--取出前一段字串後剩餘的字串
SET @InputString = RIGHT(@InputString, LEN(@InputString) - @CIndex)
SET @CIndex=CHARINDEX(',',@InputString)
END
參考連結
http://mydiamond.pixnet.net/blog/post/22415645-sql-split
留言
張貼留言