Tuesday, October 23, 2012

Check existence of global temp table



if object_id('tempdb..##deleteme') is not null
begin
    drop table ##deleteme
end

Monday, October 8, 2012

Unpivot




SELECT [Epoch], [CustomerID], [EdgeNodeID], MediaTypes, Bytes
FROM
   (SELECT top 1000 [Epoch], [CustomerID], [EdgeNodeID], [HTTP], [HTTPS], [WMS], [FMS], [WAC], [WACS]
   FROM [NEW_BandwidthByNodeAggs] (nolock)) p
UNPIVOT
   (Bytes FOR MediaTypes IN
      ([HTTP], [HTTPS], [WMS], [FMS], [WAC], [WACS])
)AS unpvt;
GO