SQL删除查询无法正常工作 [英] SQL delete query not working properly

查看:100
本文介绍了SQL删除查询无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在数据库表中发现了一些名为Dwg_Register的重复记录。现在我运行以下查询来删除它们。



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' 





我可以清楚地看到表中有16个重复记录,包含这些字段在上面的查询中提到重复...但是当我在SQL服务器中执行此命令时...成功执行但结果是(0)记录生效。



有人可以请解释SQL服务器实际上是什么。



谢谢。



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.

推荐答案

你确定吗Dwg_Ref和Title列实际上包含字符串值'NULL'?如果它们包含实际的 null 值,则它们将不匹配,并且WHERE子句将失败。也许你的意思是:

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:
DELETE FROM PIMS.dbo.Dwg_Register
WHERE Dwg_Ref IS NULL AND Title IS NULL AND [Status] = 'Approved As Noted'


您好,



请试试这个代码



Hi ,

Please try this code

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


这篇关于SQL删除查询无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆