9

I have a temparory table.temp table is created using select into statement.

Temp table columns are dynamically created .column numbers may vary.

For eg.
Temparory table
ID,Addrss1,Address2,Address3

ID, Address1,Address2,Address3,Address4,Address5.....

All temp columns have the First column as ID.I need to create a view with base table and temp table

I need to avoid the first column of the temporary table in the select statement of the view.I cannot take temp.*.it will take ID.I do not want ID in the select statement.

Any help appreciated

4

1 回答 1

18

只需尝试以下脚本:

/* Get the data into a temp table */
SELECT * INTO #TempTable
FROM YourTable
/* Drop the cloumns that are not needed */
ALTER TABLE #TempTable
DROP COLUMN ColumnToDrop
/* Get results and drop temp table */
SELECT * FROM #TempTable
DROP TABLE #TempTable
于 2013-06-26T09:40:24.600 回答