0

I found some duplicate records in my database table called Dwg_Register. Now I am running the following query to delete them.

Delete FROM PIMS.dbo.Dwg_Register WHERE Dwg_Ref = 'NULL' AND Title = 'NULL' AND [Status] = 'Approved As Noted'

I can clearly see that there are 16 duplicate records found in the table having these fields mentioned in the above query repeating ... but when I execute this command in SQL server .. successfully executes but result is (0) records effected.

Can someone pls explain what is actually goin on in SQL server.

Thank you.

  • 3
    Don't use `='NULL'`, use `Dwg_Ref is null`, etc. The way you have it written it looks like you have a string value of `'null'`. – Taryn Aug 29 '13 at 10:29
  • possible duplicate of [SQL is null and = null](http://stackoverflow.com/questions/9581745/sql-is-null-and-null) – Taryn Aug 29 '13 at 10:32

2 Answers2

3

Try:

DELETE FROM PIMS.dbo.Dwg_Register
WHERE Dwg_Ref IS NULL
AND Title IS NULL
AND [Status] = 'Approved As Noted'

When selecting NULL values in SQL you must use IS NULL instead of = 'NULL'

Lewis
  • 789
  • 8
  • 20
0

Use IS NULL instead of = 'NULL'

= 'NULL' will try to match with string NULL

Abhishek Singh
  • 10,243
  • 22
  • 74
  • 108