user2534035
user2534035

Reputation:

SQL Delete query non-functional

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.

Upvotes: 0

Views: 54

Answers (2)

Abhishek Singh
Abhishek Singh

Reputation: 9745

Use IS NULL instead of = 'NULL'

= 'NULL' will try to match with string NULL

Upvotes: 0

Lewis
Lewis

Reputation: 789

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'

Upvotes: 3

Related Questions