我使用的是SQL Server。
有2个数据库,old
和new
个。
数据库关系结构完全相同。
区别在于:
问题是找到将数据从旧数据库导入新数据库的方法。
答案 0 :(得分:5)
答案 1 :(得分:0)
你可以写一个select into query,但首先考虑eric的方法。我只是将其作为替代方案添加。
USE AdventureWorks2008R2;
GO
SELECT c.FirstName, c.LastName, e.JobTitle, a.AddressLine1, a.City,
sp.Name AS [State/Province], a.PostalCode
INTO dbo.EmployeeAddresses
FROM Person.Person AS c
JOIN HumanResources.Employee AS e
ON e.BusinessEntityID = c.BusinessEntityID
JOIN Person.BusinessEntityAddress AS bea
ON e.BusinessEntityID = bea.BusinessEntityID
JOIN Person.Address AS a
ON bea.AddressID = a.AddressID
JOIN Person.StateProvince as sp
ON sp.StateProvinceID = a.StateProvinceID;
GO
参考:msdn
使用“as”语句,您需要编写目标的列名,以便列匹配。