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
 MSSQL Link Servers

Author  Topic 

Gerald30
Yak Posting Veteran

62 Posts

Posted - 2012-03-07 : 06:30:25
Hello.

I'm just new in MSSQL can you help me out.

I have successfully link 2 databases MySQL and MSSQL.

My main Database is on MySQL, I have created a procedure to copy the content of MySQL table then insert them to MSSQL Table.

Now what I want is to update the tables in MSSQL if there is and update that was done on MySQL database.

I have tried to use these query but I think it updates all the records even there are no changes made.

update usr2
set usr2.name2 = ru.name
FROM openquery(MYSQL, 'SELECT * FROM password.table_usr1') ru
where usr2.oid = ru.idtable_usr1.

Please Help me out.

Thank you very much in advance.

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2012-03-07 : 08:46:38
add to the WHERE clause:
AND usr2.name2 <> ru.name


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

Gerald30
Yak Posting Veteran

62 Posts

Posted - 2012-03-07 : 18:36:43
Thanks bro. I will check this one.
Go to Top of Page

Gerald30
Yak Posting Veteran

62 Posts

Posted - 2012-03-07 : 18:43:27
Thanks Fred this one's really work.

Thank you.
Go to Top of Page
   

- Advertisement -