Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Link Server.

Author  Topic 

Gerald30
Yak Posting Veteran

62 Posts

Posted - 2012-10-10 : 07:10:18
Hello Guys

We are currently Migrating from MYSQL to MSSQL.

I want to insert the Records from MYSQL to MSSQL but not all.

I only want to insert only the records that doesnt exist in MSSQL table.

How can I do that?

Is it possible to check all the data that exist in MYSQL and Doesnt Exist in MSSQL?

Please help me

Thank you

sunitabeck
Master Smack Fu Yak Hacker

5155 Posts

Posted - 2012-10-10 : 07:15:41
You can set up a linked server to MySql and use OPENQUERY to get the data, compare to what you already have and insert records that do not exist in MSSQL. This page has some information on how to set it up: http://www.sqlservercentral.com/articles/MySQL/88366/

However, another approach, which may perhaps be easier and more predictable is to simply bring in ALL the data from MySQL into a staging table in MSSQL. Once you have it there, writing a query to pick only the rows that you need from the staging table and inserting into your target table is easy. To bring in all the data from MySQL, you can use SSIS, or even Import/Export Wizard in SQL Server. (right click on the database name in object explorer in SSMS and select Tasks -> Import Data
Go to Top of Page
   

- Advertisement -