Pivot table: saving it after creation: insert into or select into


i wrote code pivot data out of table required format.  query works dont see how save resultset as temp table.

i tried "insert into..." or "select * (pivot subquery here) temp",... no success.

any comments appreciated?

 

here sample of 1 way this, following creates temp table named #test , loads result of pivot query

  use adventureworks go select vendorid, [164] as emp1, [198] as emp2, [223] as emp3, [231] as emp4, [233] as emp5 into #test from  (select purchaseorderid, employeeid, vendorid from purchasing.purchaseorderheader) as p pivot ( count (purchaseorderid) for employeeid in ( [164], [198], [223], [231], [233] ) ) as pvt;  
tom



SQL Server  >  Transact-SQL



Comments

Popular posts from this blog

Conditional formatting a graph vertical axis in SSRS 2012 charts

Register with Power BI failed

SQL server replication error Cannot find the dbo or user defined function........