Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Dear Sir ,I want to see record in sql like belowsuppose i have diffrent type like A ,B each having multiple data i wanna see each data in single rowTYPE DATAA 1A 2A 3B 4B 5PLZX GUGGESTRegards,Vipin jhaVipin jha
RickD
Slow But Sure Yak Herding Master
3608 Posts
Posted - 2012-01-30 : 05:54:06
What do you mean a single row? Do you mean you want to PIVOT the results? if so, there are many examples of how to use pivot for this kind of issue. A couple of easy ones to follow:http://blogs.msdn.com/b/craigfr/archive/2007/07/03/the-pivot-operator.aspxhttp://blog.sqlauthority.com/2008/06/07/sql-server-pivot-and-unpivot-table-examples/
visakh16
Very Important crosS Applying yaK Herder
52326 Posts
Posted - 2012-01-30 : 11:26:55
may be this?
SELECT [Type],STUFF((SELECT ',' + DATA FROM table WHERE [TYPE] = t.[TYPE] ORDER BY [DATA] FOR XML PATH('')),1,1,'') AS datavaluesFROM (SELECT DISTINCT [TYPE] FROM table)t
------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/