How to select all the columns of a table except one column?

前端 未结 13 2434
被撕碎了的回忆
被撕碎了的回忆 2020-12-14 05:43

How to select all the columns of a table except one column?

I have nearly 259 columns I cant mention 258 columns in SELECT statement.

Is there

13条回答
  •  半阙折子戏
    2020-12-14 06:11

    You can use this approach to get the data from all the columns except one:-

    1. Insert all the data into a temporary table
    2. Then drop the column which you dont want from the temporary table
    3. Fetch the data from the temporary table(This will not contain the data of the removed column)
    4. Drop the temporary table

    Something like this:

    SELECT * INTO #TemporaryTable FROM YourTableName
    
    ALTER TABLE #TemporaryTable DROP COLUMN Columnwhichyouwanttoremove
    
    SELECT * FROM #TemporaryTable 
    
    DROP TABLE #TemporaryTable 
    

提交回复
热议问题