Solved

SQL Statement Syntax Error

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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

Suggested Solutions

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
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 set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

809 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