I know this is a task that can't be unique, but I can't seem to find a way to do what I'm thinking in my searches and reading, so if it's not possible, I'd like to know if I'm choosing the best alternative.
Simple case of moving information on people from the old database to the new. The problem is that the old schema has the address on each row, and we are breaking it out into its own Address table for the new.
What I want to do is something like this:
INSERT INTO [newDB].[dbo].[Persons] ([FirstName], [LastName], [AddressId], [SSN])
SELECT
p.[Firstname],
p.[Lastname],
AddressId =
(
-- The result of inserting the address into the
-- table or the existing address' ID
),
p.[SSN]
FROM [oldDB].[dbo].[tblPersons] p
Is there a way to do that which I am unable to find, or should I first get the addresses in and then match, or something I'm missing entirely? Any help would be appreciated, this is the first time I've had to work at bringing someone else's data forward and my unwarranted optimism won't hole out much longer. ;)