Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL Server Delete Query 1

Status
Not open for further replies.

rwn

Technical User
Dec 14, 2002
420
US
I have this Delete Query that works fine in Access, but in SQL Server Management Studio it shows this error.

QUERY;
UPDATE RFQ INNER JOIN Quote ON RFQ.RFQ = Quote.RFQ SET RFQ.Status = 'Lost', Quote.Status = 'Expired'
WHERE (((RFQ.Status)='active') AND ((Quote.Status)='active') AND ((RFQ.Quote_Date)<='7/1/2010'));

ERROR:
Msg 156, Level 15, State 1, Line 1
Incorrect syntax near the keyword 'INNER'.
Msg 102, Level 15, State 1, Line 2
Incorrect syntax near 'RFQ'.
 
There are a couple of issues here.

1. You can only update data in one table at a time.
2. Your syntax for SQL Server is wrong.

Code:
UPDATE RFQ
SET    RFQ.Status = 'Lost'
From   RFQ 
       INNER JOIN Quote 
         ON RFQ.RFQ = Quote.RFQ 
WHERE  RFQ.Status = 'active'
       AND Quote.Status='active'
       AND RFQ.Quote_Date<='7/1/2010';

UPDATE Quote
SET    Quote.Status = 'Expired'
From   RFQ 
       INNER JOIN Quote 
         ON RFQ.RFQ = Quote.RFQ 
WHERE  (RFQ.Status='active' Or RFQ.Status = 'Lost')
       AND Quote.Status='active' AND RFQ.Quote_Date<='7/1/2010';

-George
Microsoft SQL Server MVP
My Blogs
SQLCop
twitter
"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top