SQL Server 2008 R2 – How to Export/Migrate Tables and PKs

azure-sql-databaseschemasql-server-2008-r2

is there a way how I can only migrate/export table names with the PKs but no other relationships like FKs? So there is no dependency between the tables. And then import them to another database?

I would like to perform this between SQL Server 2008 R2 and Azure SQL.

Best Answer

3 ways you can do this.

  1. Using SQL Azure Migration Wizard which you can download from here. One catch here as this is maintained by community, you might not have the most recent schema to compare. Using this tool you can choose to deselect foreign keys and other items. You are in this page click advanced.enter image description here

Then you can deselect foreign keys.

enter image description here

  1. In my opinion this the best solution for you as this will always have latest schema but I doubt if SQL 2008 R2 can create a solution with new SSDT. General idea is once you create a solution you can delete/modify objects (FK in this case) and rebuild the project. Once you clear up FK you can deploy.

  2. Create an empty database. Script out tables without FK and then run the script against empty database in cloud. In SSMS right click the database, go to task-->generate script...-->set scripting options. Then set foreign key to false.enter image description here