snippetMinor
SQL Server 2008 R2 - How to export/migrate only tables and their PKs
Viewed 0 times
tables2008sqlandpksmigrateexporthowserveronly
Problem
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.
I would like to perform this between SQL Server 2008 R2 and Azure SQL.
Solution
You can try any of these methods given in How to copy tables from one database to another in SQL Server by Ahmad Yaseen:
1) Using SELECT INTO Query
the SELECT INTO SQL statement. This statement will create the tables in the destination database first, then it will copy the data to these tables. If you manage to copy the database objects such as the indexes and constraints, you need to generate script for it individually, after that you need to apply the scripts to the destination database.
2) Using SQL Server Export / Import wizard
Another method that can be used to copy tables from the source database to the destination one is the SQL Server Export and Import wizard, which is available in SQL Server Management Studio. You have the choice to export from the source database or import from the destination one in order to transfer the data.
3) Using Generate Scripts
SQL Server provides another way to generate script for the SQL Server databases with its objects and data. This script can be used to copy the tables’ schema and data from the source database to the destination one in our case.
4)Using the ApexSQL Diff and ApexSQL Data Diff combination
ApexSQL Diff is a useful SQL tool that can be used to find the differences between the databases from schema side and generate synchronization script to create these tables in the destination database in the correct order.
ApexSQL Data Diff also is another SQL tool that can be used to find the differences between the databases from data side and generate synchronization script to insert the data in the destination database tables, taking into consideration the IDENTITY columns.
1) Using SELECT INTO Query
the SELECT INTO SQL statement. This statement will create the tables in the destination database first, then it will copy the data to these tables. If you manage to copy the database objects such as the indexes and constraints, you need to generate script for it individually, after that you need to apply the scripts to the destination database.
2) Using SQL Server Export / Import wizard
Another method that can be used to copy tables from the source database to the destination one is the SQL Server Export and Import wizard, which is available in SQL Server Management Studio. You have the choice to export from the source database or import from the destination one in order to transfer the data.
3) Using Generate Scripts
SQL Server provides another way to generate script for the SQL Server databases with its objects and data. This script can be used to copy the tables’ schema and data from the source database to the destination one in our case.
4)Using the ApexSQL Diff and ApexSQL Data Diff combination
ApexSQL Diff is a useful SQL tool that can be used to find the differences between the databases from schema side and generate synchronization script to create these tables in the destination database in the correct order.
ApexSQL Data Diff also is another SQL tool that can be used to find the differences between the databases from data side and generate synchronization script to insert the data in the destination database tables, taking into consideration the IDENTITY columns.
Context
StackExchange Database Administrators Q#172505, answer score: 2
Revisions (0)
No revisions yet.