Exclude a column using SELECT * [except columnA] FROM tableA?
You can try it this way:
/* Get the data into a temp table */SELECT * INTO #TempTableFROM YourTable/* Drop the columns that are not needed */ALTER TABLE #TempTableDROP COLUMN ColumnToDrop/* Get results and drop temp table */SELECT * FROM #TempTableDROP TABLE #TempTable
No.
Maintenance-light best practice is to specify only the required columns.
At least 2 reasons:
- This makes your contract between client and database stable. Same data, every time
- Performance, covering indexes
Edit (July 2011):
If you drag from Object Explorer the Columns
node for a table, it puts a CSV list of columns in the Query Window for you which achieves one of your goals
If you don't want to write each column name manually you can use Script Table As
by right clicking on table or view in SSMS like this:
Then you will get whole select query in New Query Editor Window then remove unwanted column like this:
Done