0

We are migrating database structures, so I have one database with the old structure and one database with the new structure (both on the same server). I want to write queries to copy data from one to the other. I am expecting to go table-by-table as the schema is different. How do I do this?

0

3 Answers 3

3

You need to provide more details to get a more specific answer, but in general you just use the three-part name:

INSERT INTO NewDB.dbo.TableName
SELECT <columns>
FROM OldDB.dbo.Tablename

Are you looking for a way to do this automatically for all the tables?

Sign up to request clarification or add additional context in comments.

Comments

1

You can write cross database queries like so

INSERT INTO NewDatabase.Schema.Table
SELECT Column1, Column2
FROM OldDatabase.Schema.Table

Comments

0

you can probably use Import data under tasks.Right Click the Target DB -> Tasks ->Import Data .You can also specify the source-> target mapping here.. and also write queries

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.