How to remove the first column from a temp table select

14,323

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
Share:
14,323

Related videos on Youtube

user1557886
Author by

user1557886

Updated on September 21, 2022

Comments

  • user1557886
    user1557886 over 1 year

    I have a temparory table.temp table is created using select into statement.

    Temp table columns 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 ID.I need to create a view with base table and temp table

    I need to avoid the first column of the temporary table in the select statement of the view.I cannot take temp.*.it will take ID.I do not want ID in the select statement.

    Any help appreciated