Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

I have the following query which works fine in MySQL:

DELETE sb 
FROM stockbatches sb 
    INNER JOIN batchestodelete btd 
ON sb.batch_batch = btd.batchno 
    AND sb.batch_part = btd.batchpart 

What I want to do is run this query on the MySQL table from SQL Server using an openquery to a linked MySQL server. I cannot get the syntax right.

Can anybody help please?

share|improve this question
add comment

1 Answer 1

According to the OPENQUERY syntax you'd have to rewrite the script in the following way:

DELETE OPENQUERY (MySQLServer, '
    SELECT sb.*
    FROM stockbatches sb 
    INNER JOIN batchestodelete btd 
    ON sb.batch_batch = btd.batchno 
    AND sb.batch_part = btd.batchpart;
');
share|improve this answer
    
Would that be the same if the batchestodelete file is on the local machine and stockbatches is on the linked server? –  user7052 Feb 28 '12 at 8:11
    
Not exactly identical... Then you'd have to build a query using tables' (4 part name)[msdn.microsoft.com/en-us/library/ms177563.aspx]. –  Marian Feb 29 '12 at 0:01
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.