split columns

  • Hai,

    I have the script output LIKe ' [product_id_1], [scan_time__sec], [focal_spot_mm], [gray_scale_bit], [detector_resolution_mm], [dimension], [image_acquisition_degree_rotation], [source_url1], [source_url2]'

    This all column name, I need to split into seperate all columns like

    [product_id_1]

    [scan_time__sec]

    [focal_spot_mm]

    [gray_scale_bit]

    Can someone guide me how need to split columns.

    Thanks.

    ARP

  • You are showing separate rows, not columns. If that what you mean?

    Is this a string you are splitting or are these columns somehow that have data in them?

  • You seem to be trying to turn columns into rows. Will one of the solutions below work for you?

    declare @sample table ([product_id_1] int,

    [scan_time__sec] int,

    [focal_spot_mm] int,

    [gray_scale_bit] int,

    [detector_resolution_mm] int,

    [dimension] int,

    [image_acquisition_degree_rotation] int,

    [source_url1] int,

    [source_url2] int)

    insert into @sample

    select 1,2,3,4,5,6,7,8,9

    select product_id_1,scan_time__sec, focal_spot_mm, gray_scale_bit from @sample

    select ca.*

    from @sample s

    cross apply (

    values

    ('product_id_1',product_id_1),

    ('scan_time_sec',scan_time__sec),

    ('focal_spot_mm',focal_spot_mm ),

    ('gray_scale_bit',gray_scale_bit )

    ) ca (colName,colValue)

    select product_id_1,ca.*

    from @sample s

    cross apply (

    values

    ('scan_time_sec',scan_time__sec),

    ('focal_spot_mm',focal_spot_mm ),

    ('gray_scale_bit',gray_scale_bit )

    ) ca (colName,colValue)

    __________________________________________________

    Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
    Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills

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

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