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
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