Click here to Skip to main content
15,893,190 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
SQL
insert into MYSQL.dbo.traffic(id,date,time,ip,resultCode,bytes,url,authuser,sitesID,usersId)
SELECT t1.id,t1.date,t1.time,t1.ip,t1.resultCode,t1.bytes,t1.url,t1.authuser,t1.sitesID,t1.usersID FROM
   OPENQUERY(MYSQL, 'SELECT * FROM mysar.traffic') T1
   INNER JOIN
   MYSQL.DBO.traffic T2 ON T1.id > T2.id


i want to transfer the data from mysql to sql server.i can create the table and insert the data for the first time is fine.how can i add the new rows in the mysql table not existing rows in the sql server table.i am using this above query i rows are drastically increase and it is 15 GB but in the MYSQL it is 70MB.Please suggest some solution
Posted
Updated 6-Aug-13 20:17pm
v2

1 solution

Try this:

SQL
INSERT INTO MYSQL.dbo.traffic(id,date,time,ip,resultCode,bytes,url,authuser,sitesID,usersId)
SELECT t1.id,t1.date,t1.time,t1.ip,t1.resultCode,t1.bytes,t1.url,t1.authuser,t1.sitesID,t1.usersID FROM
   OPENQUERY(MYSQL, 'SELECT * FROM mysar.traffic') T1
   LEFT OUTER JOIN MYSQL.DBO.traffic T2 
     ON T1.id = T2.id
   WHERE T1.id IS NULL -- Filter for non-existing rows
 
Share this answer
 
Comments
kalisiddayya 7-Aug-13 6:45am    
nothing is return
Kuthuparakkal 7-Aug-13 13:04pm    
that means you've everything in your table; dont need to reinsert... delete 1 or two records and try

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900