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.
Author |
Topic |
sqlpal2007
Posting Yak Master
200 Posts |
Posted - 2012-11-27 : 10:34:39
|
Hello All,Below result set I need to display in rows as columns.The result is coming from 3 different replciation servers and I need to compare the record counts between them.Server Database Table RowsSrv1 DB1 Tbl1 2000Srv1 DB1 Tbl2 1000Srv1 DB2 Tbl1 100Srv2 DB1 Tbl1 2000Srv2 DB1 Tbl2 1000Srv2 DB2 Tbl1 100Srv3 DB1 Tbl1 2000Srv3 DB1 Tbl2 1000Srv3 DB2 Tbl1 100Result should look like thisDatabase Table Server1 Rows Server2 Rows Server3 RowsDB1 Tbl1 Srv1 2000 Srv2 2000 Srv3 2000DB1 Tbl2 Srv1 1000 Srv2 1000 Srv3 1000DB2 Tbl1 Srv1 100 Srv2 100 Srv3 100Can anyone please help with the query?Thanks,-Pal |
|
Elizabeth B. Darcy
Starting Member
39 Posts |
Posted - 2012-11-27 : 11:32:54
|
If you do not need the (in my view the superfluous - it does not add any additional information) Server1,Server2,Server3 columns, you can easily use the PIVOT operator like soSELECT *FROM tblPIVOT( MAX(ROWS) FOR [Server] IN ([Srv1],[Srv2],[Srv3]) )P ________________________________________-- Yes, I am indeed a fictional character. |
|
|
|
|
|