Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


split columns


split columns

Author
Message
antonyp 46888
antonyp 46888
Valued Member
Valued Member (62 reputation)Valued Member (62 reputation)Valued Member (62 reputation)Valued Member (62 reputation)Valued Member (62 reputation)Valued Member (62 reputation)Valued Member (62 reputation)Valued Member (62 reputation)

Group: General Forum Members
Points: 62 Visits: 40
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
Steve Jones
Steve Jones
SSC-Dedicated
SSC-Dedicated (36K reputation)SSC-Dedicated (36K reputation)SSC-Dedicated (36K reputation)SSC-Dedicated (36K reputation)SSC-Dedicated (36K reputation)SSC-Dedicated (36K reputation)SSC-Dedicated (36K reputation)SSC-Dedicated (36K reputation)

Group: Administrators
Points: 36318 Visits: 18752
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?

Follow me on Twitter: @way0utwest
Forum Etiquette: How to post data/code on a forum to get the best help
My Blog: www.voiceofthedba.com
The Dixie Flatline
The Dixie Flatline
Hall of Fame
Hall of Fame (3.4K reputation)Hall of Fame (3.4K reputation)Hall of Fame (3.4K reputation)Hall of Fame (3.4K reputation)Hall of Fame (3.4K reputation)Hall of Fame (3.4K reputation)Hall of Fame (3.4K reputation)Hall of Fame (3.4K reputation)

Group: General Forum Members
Points: 3398 Visits: 6899
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
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search