Solved

SQL Statement Syntax Error

Posted on 2014-03-14
3
428 Views
Last Modified: 2014-03-14
I have a syntax error that is driving ne crazy. The SQL statement below works OK.

Select * FROM [JDE_PRODUCTION].[PRODDTA].[F3111] T1
INNER JOIN [dbo].[xls(GDS-8567-03122-14-01)] T2
On T1.WMDCTO = T2.xlsDcto and T1.WMDOCO = T2.xlsDOCO
WHERE (T1.WMMCU='       22101')


But, this SQL statement has a Syntax error. Anyone out there can help me resolve the issue?

Begin Tran
DELETE FROM [JDE_PRODUCTION].[PRODDTA].[F3111] T1
INNER JOIN [dbo].[xls(GDS-8567-03122-14-01)] T2
On T1.WMDCTO = T2.xlsDcto and T1.WMDOCO = T2.xlsDOCO
WHERE (T1.WMMCU='       22101')
Rollback Tran

Error msg:
Msg 102, Level 15, State 1, Line 2
Incorrect syntax near 'T1'.


I cannot find the bug in the above SQL statement. HELP!

tw
0
Comment
Question by:Tom Winslow
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 16

Expert Comment

by:DcpKing
ID: 39929038
Not connected to a SQL Server right now to try it, but I think this works:

DELETE FROM T1
from [JDE_PRODUCTION].[PRODDTA].[F3111] T1
INNER JOIN [dbo].[xls(GDS-8567-03122-14-01)] T2 
On T1.WMDCTO = T2.xlsDcto and T1.WMDOCO = T2.xlsDOCO
WHERE (T1.WMMCU='       22101')

Open in new window


I'll check it when I get into work :)


hth

Mike
0
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
ID: 39929130
I confirm above idea to work correctly, when deleting with a join, you have to "first" specify which table to delete from, actually. but the syntax has a small issue:
DELETE T1
FROM [JDE_PRODUCTION].[PRODDTA].[F3111] T1
INNER JOIN [dbo].[xls(GDS-8567-03122-14-01)] T2 
On T1.WMDCTO = T2.xlsDcto and T1.WMDOCO = T2.xlsDOCO
WHERE (T1.WMMCU='       22101') 

Open in new window

0
 

Author Closing Comment

by:Tom Winslow
ID: 39929211
Thanks!
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
Via a live example, show how to shrink a transaction log file down to a reasonable size.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question