Update statement error: Subquery returned more than 1 value(更新语句错误:子查询返回超过 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?
这篇关于更新语句错误:子查询返回超过 1 个值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:更新语句错误:子查询返回超过 1 个值
基础教程推荐
- SQL Server 2016更改对象所有者 2022-01-01
- ERROR 2006 (HY000): MySQL 服务器已经消失 2021-01-01
- 使用pyodbc“不安全"的Python多处理和数据库访问? 2022-01-01
- 无法在 ubuntu 中启动 mysql 服务器 2021-01-01
- 如何在 SQL Server 的嵌套过程中处理事务? 2021-01-01
- 将数据从 MS SQL 迁移到 PostgreSQL? 2022-01-01
- Sql Server 字符串到日期的转换 2021-01-01
- 在 VB.NET 中更新 SQL Server DateTime 列 2021-01-01
- SQL Server 中单行 MERGE/upsert 的语法 2021-01-01
- SQL Server:只有 GROUP BY 中的最后一个条目 2021-01-01