Quantcast
Channel: Teradata Forums - Database
Viewing all articles
Browse latest Browse all 14773

Cross tab - Pivot - response (8) by elvicio

$
0
0

SET NOCOUNT ON;
CREATE TABLE #temp(
 [table1] [int] NULL,
 [table2] [int] NULL,
 [table3] [int] NULL,
 [table4] [int] NULL
 
) ON [PRIMARY]
 
INSERT #temp
SELECT
 
 [table1] ,
 [table2] ,
 [table3] ,
 [table4]
 
FROM (
SELECT so.name [TableName], si.rows [RowCount]
--   SELECT *
FROM sysobjects so
INNER JOIN sysindexes si on si.id = OBJECT_ID(so.name)
AND SI.INDID <2
WHERE so.xtype = 'U'
) base
PIVOT (MAX([RowCount]) FOR
[TableName] IN (
[table1] ,
 [table2] ,
 [table3] ,
 [table4]
 
 )) piv
 
 


Viewing all articles
Browse latest Browse all 14773

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>