Click here to Skip to main content
15,888,610 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I found some duplicate records in my database table called Dwg_Register. Now I am running the following query to delete them.

SQL
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.
Posted
Comments
Hitesh Gohel 29-Aug-13 6:46am    
Hi,
In your table fields Dwg_Ref,Title,[Status] which type of Data Type?

Are you sure that the Dwg_Ref and Title columns actually contain the string value 'NULL'? If they contain actual null values, then they will not match, and the WHERE clause will fail. Perhaps you meant:
SQL
DELETE FROM PIMS.dbo.Dwg_Register
WHERE Dwg_Ref IS NULL AND Title IS NULL AND [Status] = 'Approved As Noted'
 
Share this answer
 
Comments
Shobhana.n 29-Aug-13 8:27am    
Agree....
Hi ,

Please try this code

SQL
Delete
FROM PIMS.dbo.Dwg_Register
WHERE
Dwg_Ref = NULL; 
AND 
Title = NULL; 
AND 
[Status] = 'Approved As Noted'
 
Share this answer
 
Comments
OriginalGriff 29-Aug-13 8:39am    
Reason for my vote of one:
"Please try this code"
Did you? Please do, before you post...

"= NULL" is not the same as "IS NULL"

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900