INSERT在SQL Server Management Studio中命令

时间:2014-10-08 08:37:03

标签: sql sql-server ssms

我正在尝试在数据库之间传输数据,但无法使INSERT工作。

USE [db1_Name]

GO

INSERT INTO [dbo].[company$Customer]

[No_]      
GO


USE [db2_Name]
GO

SELECT 

[No_]     
FROM [dbo].[company$Customer]

GO

2 个答案:

答案 0 :(得分:2)

将脚本更改为

INSERT INTO DbnameTarget.[dbo].[company$Customer]
SELECT
Colum1,Colum2
FROM DbnameSource.[dbo].[company$Customer]

用自己的

替换Dbname,列

答案 1 :(得分:0)

  Select * into [DestinationDB].dbo.tableName 
  from [SourceDB.dbo].SourceTable 

(或)       select * into [Destinationserver]。[DestinationDB] .dbo.tablename       来自[Sourceserver]。[SourceDB] .dbo.tablename