我有一個包含59列的表Table1
。 Table2
是Table1
的一個副本,最後一列爲COLUMN 60
。因此table2
有60列。SQL:使用SELECT將INSERT數據插入帶有額外列的表中
我試圖複製從table1
值來table2
和table2
額外列的值設置爲「價值」
像這樣的事情
INSERT INTO Table2
SELECT * FROM Table1, 'value' AS 'COLUMN 60'
我怎樣才能做到這一點?使用上面的代碼給我一個錯誤:
An explicit value for the identity column in table 'TableLocation' can only be specified when a column list is used and IDENTITY_INSERT is ON.
我不想指定列名稱,因爲它們太多。
如果你不能使用所有列('SELECT *'),因爲其中一列是'IDENTITY'列 - 那麼你必須指定**所有**列,你想插入並且你想從'table1'中選擇....(不管怎樣,總是**總是顯式地指定你想要插入和選擇的列) –