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.

Mozbius
  • 3
  • 1
  • 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. – Thom A Feb 20 '19 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. – Sean Lange Feb 20 '19 at 14:57
  • Apparently it is legal syntax. Not a fan of that. – Thom A Feb 20 '19 at 15:04

1 Answers1

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.

Tab Alleman
  • 31,483
  • 7
  • 36
  • 52
  • This is more of a comment, rather than an answer. – Thom A Feb 20 '19 at 14:58
  • I don't agree. It's not a request for clarification or a suggestion for improving the question. It resolves the OPs confusion. – Tab Alleman Feb 20 '19 at 15:03
  • This is certainly, at best, a Link only answer. – Thom A Feb 20 '19 at 15:07
  • 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. – Tab Alleman Feb 20 '19 at 15:11
  • @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. – Tab Alleman Feb 20 '19 at 15:28