Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Delele with inner join

Author  Topic 

JJins
Yak Posting Veteran

81 Posts

Posted - 2010-10-20 : 16:28:59
Here is the delete statement that is not working for me. It is saying the error is happening around the INNER Join. Any Ideas


Delete From RateData INNER JOIN
Programs ON RateData.ProgramID = Programs.ProgramID
where ratedata.coverageid = 1 programs.state = 'NJ' and programs.policytype = 6




then the error is....Msg 156, Level 15, State 1, Line 1
Incorrect syntax near the keyword 'INNER'.

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-10-20 : 16:32:34
You are missing an AND in the WHERE clause. Here you go:

Delete r
From RateData
INNER JOIN Programs p
ON r.ProgramID = p.ProgramID
where r.coverageid = 1 and p.state = 'NJ' and p.policytype = 6

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

JJins
Yak Posting Veteran

81 Posts

Posted - 2010-10-20 : 16:46:48
I think you just did the exact same thing I had. maybe this will help.......database = Rating_2 and table = ratedata. and the table I want to inner join with is programs.

this is the error I recieved when i ran your code.
Msg 4104, Level 16, State 1, Line 1
The multi-part identifier "r.ProgramID" could not be bound.
Msg 208, Level 16, State 1, Line 1
Invalid object name 'r'.
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-10-20 : 16:53:38
Actually mine is different as mine has the missing AND.

Mine has a typo though:

Delete r
From RateData r
INNER JOIN Programs p
ON r.ProgramID = p.ProgramID
where r.coverageid = 1 and p.state = 'NJ' and p.policytype = 6

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page
   

- Advertisement -