Skip to content

Instantly share code, notes, and snippets.

@marsen
Created May 26, 2014 00:43
Show Gist options
  • Save marsen/a6dbdc934b59b12a934d to your computer and use it in GitHub Desktop.
Save marsen/a6dbdc934b59b12a934d to your computer and use it in GitHub Desktop.
SQL Slipt
CREATE FUNCTION [dbo].[UF_SliptToTable]
(
@psCSString VARCHAR(8000)
)
RETURNS @otTemp TABLE(sID VARCHAR(100))
AS
BEGIN
DECLARE @sTemp VARCHAR(100)
WHILE LEN(@psCSString) > 0
BEGIN
SET @sTemp = LEFT(@psCSString, ISNULL(NULLIF(CHARINDEX(',', @psCSString) - 1, -1),
LEN(@psCSString)))
SET @psCSString = SUBSTRING(@psCSString,ISNULL(NULLIF(CHARINDEX(',', @psCSString), 0),
LEN(@psCSString)) + 1, LEN(@psCSString))
INSERT INTO @otTemp VALUES (@sTemp)
END
RETURN
END
GO
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment