Output strings separated by delimiters into variables

  • Hi,

    This is just an example.

    I have a column value as shown, Column_value = Test1~Test2~Test3~Test4

    I need to write a script that will extract each value and put it in different variables

    Eg: @test1 = Test1

    @test2 = Test2

    @test3 = Test3

    @test4 = Test4

    How can i do this in a simple T-sql script?

  • Unless it's always 4 values (or some other static number), you probably need to use a string-parsing function. There are several out there that you can use. Look up Jeff Moden's article on the subject for some suggestions.

    If it's a fixed number of entries, there are easier ways to do it.

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

Viewing 2 posts - 1 through 1 (of 1 total)

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