2010-04-23 157 views

回答

3

如果他們是在同一臺服務器上,並且具有相同的表結構,你可以這樣做:

Truncate Table DBProduction.dbo.testTable 
Go 

Insert Into DBProduction.dbo.testTable 
Select * From DBLocal.dbo.testTable 

如果它們是在不同的服務器,你可以運行截斷聲明如上所示,然後右鍵單擊DBProduction並選擇導入數據。這將啓動向導併爲您導入數據。

編輯: 我還應該補充說,如果表結構不同,你應該Drop Table DBProduction.dbo.testTable,然後使用導入數據嚮導導入(並且默認重新創建)DBProduction中的testTable。

編輯2:

如果你想插入(沒有列出所有列)將列設置爲標識,你需要做到以下幾點:

Set Identity_Insert DBProduction.dbo.testTable On 

    Insert Into DBProduction.dbo.testTable 
    Select * From DBLocal.dbo.testTable 

Set Identity_Insert DBProduction.dbo.testTable Off 

這將暫時忽略身份播種。

HTH

巴里

+0

需要列出列名,否則提示錯誤:表「DBProduction.dbo.testTable」的標識列的顯式值時,使用的列清單,才能指定和IDENTITY_INSERT已打開。 – coure2011 2010-04-23 07:15:11

相關問題