I'm having a little trouble getting this SQL Statement right. I'm fairly new to SQL so my apologies if I made an obvious mistake. I have two tables we'll call them Table1 and Table2. Both tables will have an ID and Type column that will be the key fields. I want to delete records from Table1 where there is not a corresponding ID and Type entry in Table2. And to throw a little more complexity into the mix I don't want to delete entries in Table1 where the ID = -99.
I have the following SQL Statement but it does not delete anything.
Delete Table1
From Table1 Right Outer Join Table2
On Table1.Type = Table2.Type AND Table1.ID = Table2.ID
Where Table2.Type Is Null AND
Table2.ID Is Null AND
Table1.ID <> -99
Can anyone help?
I have the following SQL Statement but it does not delete anything.
Delete Table1
From Table1 Right Outer Join Table2
On Table1.Type = Table2.Type AND Table1.ID = Table2.ID
Where Table2.Type Is Null AND
Table2.ID Is Null AND
Table1.ID <> -99
Can anyone help?