troubleshooting Question

In sql, how to roll up multiple rows to only one row.

Avatar of Terry Ambrosius
Terry Ambrosius asked on
SQLXMLMicrosoft SQL Server
4 Comments1 Solution568 ViewsLast Modified:
Hello,   did not think this would be to difficult, but cannot find a clean way to do this.     First I am not a SQL person by no means.
I have a table with multiple rows of data and need to roll it up to one row of data.  

spec       code
12345    abc
12345    def
67891    xyz
67891    rst

need the data to look like
spec      code1 code2
12345    abc     def
67891    xyz      rst

I tried the xml feature, but how to get rid of the xml tags in the output,  
Tried stuff command, but code not get it to work yet.  

Must be an easier way.     Any help/example would be appreciated.
Would be creating a view once I figure out how to make that work.
Join our community to see this answer!
Unlock 1 Answer and 4 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros