Snargables (3/7/2013)
NOTICE THE DESIRED OUTPUT ON THE BOTTOM.SELECT 'table1' TABLENAME
,'col1' COLNAME
INTO #temp
UNION ALL
SELECT 'table1'
,'col2'
UNION ALL
SELECT 'table1'
,'col3'
UNION ALL
SELECT 'table2'
,'col1'
UNION ALL
SELECT 'table2'
,'col2'
UNION ALL
SELECT 'table3'
,'col1'
SELECT *
FROM #temp
--DESIRED OUTPUT ID COL:
--ID TABLENAMECOLNAME
--1 table1 col1
--2 table1 col2
--3 table1 col3
--1 table2 col1
--2 table2 col2
--1 table3 col1
Okay, so what is the problem?