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.

 All Forums
 SQL Server 2012 Forums
 Transact-SQL (2012)
 transpose rows to colms

Author  Topic 

bvv
Starting Member

1 Post

Posted - 2014-08-28 : 12:24:24
hi there,

i would like to reach out you on transposing rows to cols.

Format:
NodeName|upsBasicIdentName|upsBasicIdentModel | upsAdvIdentSerialNumber | upsAdvIdentDateOfManufacture | upsBasicBatteryLastReplaceDate


i have this query. the values of each are under status. thank you for your help!

SELECT
Nodes.Caption AS NodeName, CustomNodePollers_CustomPollers.MIB AS MIB, CustomNodePollerStatus_CustomPollerStatus.Status AS Status

FROM

((Nodes INNER JOIN CustomPollerAssignment CustomNodePollerAssignment_CustomPollerAssignment ON (Nodes.NodeID = CustomNodePollerAssignment_CustomPollerAssignment.NodeID)) INNER JOIN CustomPollers CustomNodePollers_CustomPollers ON (CustomNodePollerAssignment_CustomPollerAssignment.CustomPollerID = CustomNodePollers_CustomPollers.CustomPollerID)) INNER JOIN CustomPollerStatus CustomNodePollerStatus_CustomPollerStatus ON (CustomNodePollerAssignment_CustomPollerAssignment.CustomPollerAssignmentID = CustomNodePollerStatus_CustomPollerStatus.CustomPollerAssignmentID)

WHERE
(
(CustomNodePollers_CustomPollers.MIB like 'PowerNet-MIB:upsBasicIdentName') Or
(CustomNodePollers_CustomPollers.MIB like 'PowerNet-MIB:upsBasicIdentModel') Or
(CustomNodePollers_CustomPollers.MIB like 'PowerNet-MIB:upsAdvIdentSerialNumber') Or (CustomNodePollers_CustomPollers.MIB like 'PowerNet-MIB:upsAdvIdentDateOfManufacture') Or (CustomNodePollers_CustomPollers.MIB like 'PowerNet-MIB:upsBasicBatteryLastReplaceDate')
)

gbritton
Master Smack Fu Yak Hacker

2780 Posts

Posted - 2014-08-29 : 07:54:23
read up on PIVOT
Go to Top of Page
   

- Advertisement -