Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CREATE FUNCTION [dbo].[explodeString] (@str VARCHAR(1024), @delimiter VARCHAR(50))
- RETURNS @table TABLE (Item VARCHAR(1024))
- BEGIN
- WHILE LEN(@str) > 0
- BEGIN
- DECLARE @index INT;
- SET @index = CHARINDEX(@delimiter, @str, 1)
- IF @index = 0 SET @index = LEN(@str) + 1
- DECLARE @substr VARCHAR(100)
- SET @substr = SUBSTRING(@str, 1, @index - 1)
- INSERT INTO @table SELECT @substr
- SET @str = SUBSTRING(@str, @index + 1, len(@str))
- END
- RETURN
- END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement