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
 Query to Delete based on a condition

Author  Topic 

jim_jim
Constraint Violating Yak Guru

306 Posts

Posted - 2011-04-24 : 12:43:28
I am trying to delete records from a table based on a condition on the table OR based on another condition from a union of two views

So the query should not delete records if either condition is true

Below is my Query and getting an error

Delete from Customer where EDate Is Not null
OR
(select * from TestTable1
union
select * from TestTable2))


Below is the error message

An expression of non-boolean type specified in a context where a condition is expected, near ')'.

Iam not sure whether my query logic is right but need help to do what I described above

Thanks

nigelrivett
Master Smack Fu Yak Hacker

3385 Posts

Posted - 2011-04-24 : 13:08:18
Not sure from that what you are trying to do - neither is the server.

Delete from Customer
where EDate Is Not null
OR
customerID in (select customerid from TestTable1
union
select customerid from TestTable2))


==========================================
Cursors are useful if you don't know sql.
SSIS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

jim_jim
Constraint Violating Yak Guru

306 Posts

Posted - 2011-04-25 : 17:29:48
Thank You.It worked
Go to Top of Page
   

- Advertisement -