Thursday, February 14, 2013

Static Pivot




select *
from
(
      select a.ObjectId, f.Name, a.Address
      from V6Addresses a
      join V6ObjectTypeFields f on a.V6ObjectTypeFieldId = f.Id
      join V6ObjectTypes t on f.V6ObjectTypeId = t.Id
      where t.Name = 'Servers'
) v
PIVOT
(
      MAX(Address)
      FOR v.Name in (ServersPrimary, ServersSecondary, ServersGateway, ServersManagement, ServersManagementGateway)
) as p

No comments:

Post a Comment