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 [##E0404FF442A04AC7BCCEC3379FBC63]
select column_name from TEMPDB.INFORMATION_SCHEMA.COLUMNS where TABLE_NAME='[##E0404FF442A04AC7BCCEC3379FBC63]'
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 [##E0404FF442A04AC7BCCEC3379FBC63]
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???
Our community of experts have been thoroughly vetted for their expertise and industry experience.
The Most Valuable Expert award recognizes technology experts who passionately share their knowledge with the community, demonstrate the core values of this platform, and go the extra mile in all aspects of their contributions. This award is based off of nominations by EE users and experts. Multiple MVEs may be awarded each year.
The Distinguished Expert awards are presented to the top veteran and rookie experts to earn the most points in the top 50 topics.