使用 SELECT * [except columnA] FROM tableA 排除列? [英] Exclude a column using SELECT * [except columnA] FROM tableA?

查看:49
本文介绍了使用 SELECT * [except columnA] FROM tableA 排除列?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们都知道要从表中选择所有列,我们可以使用

We all know that to select all columns from a table, we can use

SELECT * FROM tableA

有没有办法在不指定所有列的情况下从表中排除列?

Is there a way to exclude column(s) from a table without specifying all the columns?

SELECT * [except columnA] FROM tableA

我知道的唯一方法是手动指定所有列并排除不需要的列.这真的很耗时,所以我正在寻找方法来节省时间和精力,以及如果表有更多/更少的列,以及未来的维护.

The only way that I know is to manually specify all the columns and exclude the unwanted column. This is really time consuming so I'm looking for ways to save time and effort on this, as well as future maintenance should the table has more/less columns.

推荐答案

你可以这样试试:

/* 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

这篇关于使用 SELECT * [except columnA] FROM tableA 排除列?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆