【发布时间】:2020-07-29 00:22:35
【问题描述】:
我有两个表,分别名为 code 和 codeTemporary。
在我将使用的代码表中
select Code from codeTemporary with (nolock)
EXCEPT
select Code from code with (nolock)
这个差值大约是1000万。
codeTemporary 表有 "Id(guid)","Code(string)","boxId(guid)"
code 表将具有相同的 Id、getdate、getdate、默认 guid、默认 guid、相同的代码、相同的 boxId、1。
insert into Code
select Id,GETDATE(),GETDATE(),'00000000-0000-0000-0000-000000000000','00000000-0000-0000-0000-000000000000',
(
select Code from code with(nolock)
EXCEPT
select Code from codeTemporary with(nolock)
) as Code
,boxId,1
from codeTemporary with(nolock)
where boxId='xxxxxx (guid)'
但该代码不起作用:
子查询返回超过 1 个值。这是不允许的,当 子查询遵循 =、!=、、>= 或当子查询用作 一个表达式。
如何将丢失的代码从codeTemporary 转移到code?
【问题讨论】:
标签: sql sql-server tsql select sql-insert