How to split string into array

  • HI folks,

    say I have a string: "asdf1, asdf2, asdf3 asdf4/asdf5/asdf6", I need to split them up to an array:

    asdf1, asdf2, asdf3,asdf4,asdf5,asdf6

    How do I write the query? Is there any kind of regular expression function or stored procedure in SQL2000?

    Thanks.

     

  • You could use REPLACE. First replace all commas with 'no space' REPLACE(string, ',', ''). Then replace all slants with a comma, and all spaces with a comma.

    -SQLBill

  • I can help you there (kind-of....)

    This was covered in good detail over at Simple Talk http://www.simple-talk.com/default.aspx

    Just look up articles by Robin Page* and look for a post on string manipulation.

    * How come I've never seen a DBA anywhere that looks as good and is as smart as she is?

    A lack of planning on your part does not constitute an emergency on mine.

  • Hey Matt, you're dead on about Robin...smart and attractive...cloning her might be the answer!

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply