OzarkSunshine
asked on
Select column_name from INFORMATION.SCHEMA.COLUMNS not working with TEMP tables
I'm creating a global temp table using a random id and then trying to get column names from that table using INFORMATION_SCHEMA. Below is an example of what I'm doing --
SELECT 'JOHN' AS FIRST_NAME,'DAVIS' AS LAST_NAME ,'CHICAGO' AS CITY INTO [##E0404FF442A04AC7BCCEC33 79FBC63]
select column_name from TEMPDB.INFORMATION_SCHEMA. COLUMNS where TABLE_NAME='[##E0404FF442A 04AC7BCCEC 3379FBC63] '
This does not work, it returns nothing under column_name. I can take that same table and copy it into another temp table, and it works.
SELECT * INTO ##OUT_LABEL FROM [##E0404FF442A04AC7BCCEC33 79FBC63]
select column_name from TEMPDB.INFORMATION_SCHEMA. COLUMNS where TABLE_NAME='##OUT_LABEL'
column_name
FIRST_NAME
LAST_NAME
CITY
What am I missing here on why this is not working???
SELECT 'JOHN' AS FIRST_NAME,'DAVIS' AS LAST_NAME ,'CHICAGO' AS CITY INTO [##E0404FF442A04AC7BCCEC33
select column_name from TEMPDB.INFORMATION_SCHEMA.
This does not work, it returns nothing under column_name. I can take that same table and copy it into another temp table, and it works.
SELECT * INTO ##OUT_LABEL FROM [##E0404FF442A04AC7BCCEC33
select column_name from TEMPDB.INFORMATION_SCHEMA.
column_name
FIRST_NAME
LAST_NAME
CITY
What am I missing here on why this is not working???
SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER