Exclude a column using SELECT * [except columnA] FROM tableA?

Clippy
Messages : 22157
Inscription : mer. 22 avr. 2026, 17:33

Exclude a column using SELECT * [except columnA] FROM tableA?

Message par Clippy »

Exclude a column using SELECT * [except columnA] FROM tableA?
Clippy
Messages : 22157
Inscription : mer. 22 avr. 2026, 17:33

Re: Exclude a column using SELECT * [except columnA] FROM tableA?

Message par Clippy »

You can try it this way:

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

```
Répondre

Revenir à « SQL Server »