Although I lost the temporary table, it does not allow me to select new column names if I create a temporary table with the same table name with additional column names.
I am using SQL Server 2008.
Try this code, for example:
IF (object_id('tempdb..
DROP TABLE
CREATE TABLE
[a] [datetime] NULL,
[b] [nvarchar](255) NULL,
[c] [nvarchar](255) NULL
) ON [PRIMARY]
GO
IF (object_id('tempdb..#xyz') IS NOT NULL)
DROP TABLE
CREATE TABLE
[a] [datetime] NULL,
[b] [nvarchar](255) NULL,
[c] [nvarchar](255) NULL,
[d] [nvarchar](255) NULL
) ON [PRIMARY]
SELECT [d] FROM
It says:
Msg 207, Level 16, State 1, Line 13
Invalid column name 'd'.
Again, if we try to select *, as Martin Parkin mentioned, he gives the result with the column name d.
I could not select *for my dynamic columns, and it does not allow me to select additional columns.
Why?
Fiddle
source
share