如何选择表格中除一列之外的所有列?

问题描述:

如何选择表格中除一列之外的所有列?

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

我有将近 259 列我不能在 SELECT 语句中提到 258 列.

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

还有其他方法吗?

您可以使用此方法从除一列之外的所有列中获取数据:-

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

  1. 将所有数据插入临时表
  2. 然后从临时表中删除不需要的列
  3. 从临时表中获取数据(这将不包含删除列的数据)
  4. 删除临时表

像这样:

SELECT * INTO #TemporaryTable FROM YourTableName

ALTER TABLE #TemporaryTable DROP COLUMN Columnwhichyouwanttoremove

SELECT * FROM #TemporaryTable 

DROP TABLE #TemporaryTable