question

Deb avatar image
Deb asked

Extraction of SQL data to a relational table

I have a table which has column called "Issue".The Issue column contains xml values like YesNo.I want to extract the values Yes,No and want to keep in a different table in different rows.I am able to do when the xml length is fixed.I want to know how to achieve this when the xml length is not fixed.Like sometimes the same Issue column will contain values like YesNoNotStarted.In this case there are 3 values to be extracted eg Yes,No ,NotStarted where in the previous case only two values.

data-import
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
JohnFx avatar image
JohnFx answered

It seems weird that an Issue can be both yes and no, but assuming that for a moment. Why bother with a separate table.

Why not just add to bit columns "Yes" and "No" and run populate them thusly:

UPDATE MyTable             
SET [Yes]= CASE WHEN ([Issue] like '%yes%') THEN 1 Else 0 END,            
    [No] CASE WHEN ([Issue] like '%no%') THEN 1 Else 0 END            
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.