Please start any new threads on our new site at http://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 Script Library
 Small CSV Parser
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Onamuji
Aged Yak Warrior

USA
504 Posts

Posted - 08/01/2002 :  09:02:56  Show Profile  Visit Onamuji's Homepage  Send Onamuji an AOL message  Reply with Quote
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)

  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.02 seconds. Powered By: Snitz Forums 2000