sql-server - 当前命令发生严重错误。 - 未知错误

标签 sql-server common-table-expression

这是我的代码。

;With CTE as
(
select
    a.rn,
    a.LongDescription as ad,
    b.LongDescription as bd
from myTabl as a
    left join myTabl as b on a.rn +1 = b.rn
where
    a.rn=1
and
    a.LongDescription = 'Eric'
)
update CTE
    set ad += ' ' + b.LongDescription
from CTE as a
    left join myTabl as b on a.rn = b.rn+1
where
    a.rn=1

我试图回答一个问题,同时尝试差异。我遇到以下错误的选项,
Msg 0, Level 11, State 0, Line 0
A severe error occurred on the current command.  The results, if any, should be discarded.
Msg 0, Level 20, State 0, Line 0
A severe error occurred on the current command.  The results, if any, should be discarded.

这是什么,我什么都没有。我的代码有什么重大错误吗?我试图用谷歌搜索它,但所有结果都将我重定向到“Microsoft Fix”。有些人可以用简单的话解释我有什么问题吗?

最佳答案

我想您需要更改设置行:

set ad = a.ad + ' ' + b.LongDescription

查看 SQL fiddle 演示 here

关于sql-server - 当前命令发生严重错误。 - 未知错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22786370/

相关文章:

c# - asp.net 缓存限制?

使用实例名称、端口和域的 Node.js 连接到 SQL Server

sql - 从记录类型的单列中拆分/提取值,将用户定义的函数应用于多行 CTE

SQL:带有参数的WITH子句?

sql-server - SQL服务器和触发器反射(reflect)了更改顺序?

SQL 删除 TOP 语句

sql-server - 获取 SQL Server 月份的周数

sqlite - WITH语句在触发器定义中起作用吗?

postgresql - 窗口函数和更多 "local"聚合

sql - 使用 SSIS 包加载数据时理解间歇性不一致的问题