?
Solved

SQL Statement Syntax Error

Posted on 2014-03-14
3
Medium Priority
?
437 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 2000 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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.
Suggested Courses

770 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