Created
August 9, 2015 11:07
-
-
Save SalihKARAHAN/78ee271939f09d6ffea9 to your computer and use it in GitHub Desktop.
String'i split eden fonksiyon
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- String'i split eden fonksiyon | |
CREATE FUNCTION fn$_GetSplitedString | |
( | |
@seperator CHAR(1) | |
, @stringList NVARCHAR(MAX) | |
) | |
RETURNS @returnTable TABLE | |
( | |
TagName NVARCHAR(100) NOT NULL | |
) | |
AS | |
BEGIN | |
DECLARE | |
@listLength BIGINT | |
, @nextTagName NVARCHAR(100) | |
, @index BIGINT | |
, @startIndex BIGINT | |
SET @listLength = LEN(@stringList) | |
SET @index = 1 | |
SET @startIndex = 1 | |
WHILE @index < @listLength | |
BEGIN | |
SET @index = CHARINDEX(@seperator, @stringList, @index) | |
IF(@index = 0) | |
BEGIN | |
SET @index = @listLength | |
END | |
SET @nextTagName = SUBSTRING(@stringList, @startIndex, @index - @startIndex) | |
SET @startIndex = @index + 1 | |
SET @index = @startIndex | |
INSERT INTO @returnTable SELECT @nextTagName | |
END | |
RETURN | |
END | |
GO |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment