How to remove the first column from temp select table

I have a tempory table.temp table created using select in statement.

Temp column tables are dynamically created. Column numbers may vary.

For eg. Temparory table ID,Addrss1,Address2,Address3 ID, Address1,Address2,Address3,Address4,Address5..... 

All temp columns have the first column as identifier. I need to create a view with a base table and temp table

I need to avoid the first column of the temporary table in the view select statement. I can not accept temp. *, it will accept an ID. I don't want an ID in a select statement.

Any help appreciated

+6
source share
1 answer

Just try below script:

 /* Get the data into a temp table */ SELECT * INTO #TempTable FROM YourTable /* Drop the cloumns that are not needed */ ALTER TABLE #TempTable DROP COLUMN ColumnToDrop /* Get results and drop temp table */ SELECT * FROM #TempTable DROP TABLE #TempTable 
+11
source

Source: https://habr.com/ru/post/948127/


All Articles