0

Admittedly I am no SQL guru but I have done my research and I am still baffled as to why SQL Studio is giving me a hard time with the following query:

DELETE
[liaison].[dbo].[LI_ENT_Entry], 
[liaison].[dbo].[LI_ENT_AppEntry], 
[liaison].[dbo].[LI_ENT_AppEntryLink]

FROM
[liaison].[dbo].[LI_ENT_Entry]

INNER JOIN 
[liaison].[dbo].[LI_ENT_AppEntry]           
ON  
[liaison].[dbo].[LI_ENT_Entry].[ID] = [liaison].[dbo].[LI_ENT_AppEntry].[LI_ENT_Entry__ID]

LEFT JOIN 
[liaison].[dbo].[LI_ENT_AppEntryLink] 
ON   
[liaison].[dbo].[LI_ENT_AppEntry].[ID] = [liaison].[dbo].[LI_ENT_AppEntryLink].[LI_ENT_AppEntry__ID_Child]

WHERE     
[liaison].[dbo].[LI_ENT_Entry].[PrimaryLangName] = 'Hamers, Patrick'

More precisely I get an "Incorrect syntax near ','" right at the first coma after the DELETE statement. Looking around the web and on StackOverflow it should have been the correct syntax. I am confused.

3
  • T-SQL doesn't work like that. A DML statement can only target one object. You will need to write 3 statements or, if these are based on foreign key relationships, you could enable cascading. Also, those links you've provided are for MySQL. MySQL and SQL Server are completely different products. Documentation on MySQL isn't relevant to SQL Server. Although some syntax is the same, every DBMS uses a different "flavour" of SQL, all of which have different functions, syntax, etc. Commented Feb 20, 2019 at 14:51
  • OMG that is legal syntax in MySql??? Talk about confusing!!! Yet another reason I am glad I don't work with that product. Commented Feb 20, 2019 at 14:57
  • Apparently it is legal syntax. Not a fan of that. Commented Feb 20, 2019 at 15:04

1 Answer 1

0

Your examples from the Web and Stack Overflow are not for SQL Server. They are for MySQL.

You cannot delete multiple tables in one statement in SQL Server.

Sign up to request clarification or add additional context in comments.

5 Comments

This is more of a comment, rather than an answer.
I don't agree. It's not a request for clarification or a suggestion for improving the question. It resolves the OPs confusion.
This is certainly, at best, a Link only answer.
Still don't agree. The text is the answer. The content of the link only supports it. Besides which it's a link to Stack Overflow, so if the link ever goes dead, there will be no link to be dead.
@Larnu however, if you think this question should be closed as a duplicate of the one I referenced, I am good with that. I was on the fence about it because the OP gave specific links to the reasons he thought his syntax was valid, and the reason those links don't apply isn't addressed in the duplicate.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.