更新语句错误:子查询返回超过 1 个值
我正在尝试更新列中的所有记录,以便它们以CD"开头,例如DCE206 将成为 CDE206.
I am trying to update all records in a column so that they start with 'CD' e.g. DCE206 would become CDE206.
UPDATE table
SET column = REPLACE(column1, 'DC', 'CD')
WHERE column1 LIKE 'DC%'
我正在使用上面的更新语句但是出现以下错误
I am using the above update statement however the following error appears
'子查询返回超过 1 个值.当子查询跟随 =、!=、<、<=、>、>= 或当子查询用作表达式时,这是不允许的.'
'Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.'
我可以在语句中更改什么来实现这一点,还是我需要研究一下使用游标.
Is there anything I can change in the statement to make this happen or do I need to look into using a cursor.
我使用的是 SQL Server 2000.
I am using SQL Server 2000.
推荐答案
你不可能从那个代码中得到这个错误.错误可能来自其他代码.
You can't possibly be getting this error from that code. The error msut be from some other peice of code.
除了在更新时运行之外还有什么吗?触发器?
Do you have anything than runs on update? A trigger?
相关文章