Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
Onamuji
Aged Yak Warrior
504 Posts |
Posted - 2002-08-01 : 09:02:56
|
I don't take credit for this small function just needed one and found robvolk's article on CSV parsing .... made a function out of it... http://www.sqlteam.com/item.asp?ItemID=2652 CREATE FUNCTION CSV (@String VARCHAR(8000), @Delimeter CHAR(1)) RETURNS TABLE AS RETURN (SELECT NULLIF(SUBSTRING(@Delimeter + @String + @Delimeter, Value, CHARINDEX(@Delimeter, @Delimeter + @String + @Delimeter, Value) - Value), '') AS Value FROM Sequences WITH (NOLOCK) WHERE Value <= LEN(@Delimeter + @String + @Delimeter) AND SUBSTRING(@Delimeter + @String + @Delimeter, Value - 1, 1) = @Delimeter AND CHARINDEX(@Delimeter, @Delimeter + @String + @Delimeter, Value) - Value > 0) |
|
|
|
|