Solved

SQL Statement Syntax Error

Posted on 2014-03-14
3
414 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
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 142

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

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

How to leverage one TLS certificate to encrypt Microsoft SQL traffic and Remote Desktop Services, versus creating multiple tickets for the same server.
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Via a live example, show how to shrink a transaction log file down to a reasonable size.
Viewers will learn how the fundamental information of how to create a table.

867 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now