SQLTeam.com | Weblogs | Forums

How to avoid using ( OR && IS NULL ) on where statment when Delete Data?

I work on SQL server 2012 I face issue when using ( OR && IS NULL ) on where statement

to Delete data it will be very slow

so How to replace ( OR AND IS NULL ) by any thing can do same thing ?

 DELETE  f
FROM    Parts.ChemicalProfiles f
INNER JOIN #TempPC t 
ON t.ChemicalID = f.ChemicalID
         WHERE  t.[status]='Not Found in Chemical Master' OR t.[status] IS NULL 

I need to replace line below on where

WHERE t.[status]='Not Found in Chemical Master' OR t.[status] IS NULL

by any thing can do same job of (OR t.[status] IS NULL) because it very slow running

so I need to rewrite statement below to enhance performance and very quickly

WHERE t.[status]='Not Found in Chemical Master' OR t.[status] IS NULL

one idea (among a lot if ideas )
is to seperate the where statement

DELETE  f
FROM    Parts.ChemicalProfiles f
INNER JOIN #TempPC t 
ON t.ChemicalID = f.ChemicalID
              WHERE  t.[status] IS NULL 

DELETE  f
FROM    Parts.ChemicalProfiles f
INNER JOIN #TempPC t 
ON t.ChemicalID = f.ChemicalID
         WHERE  t.[status]='Not Found in Chemical Master'

thank you for reply
can i do both condition on one delete
without using two delete

you can

but if its much faster using seperate deletes

WHY NOT

OK this is correct
only for knowledge How to use In operator SQL server on my case

i don't think you can use IN for checking Nulls

if you are thinking about putting both the conditions
in 1 clause .. then try another idea

thanks