我有两个列表A和B(列表).如何以最便宜的方式确定它们是否相等?我可以写一些类似'(A减B)联合(B减A)=空集'或将它们连接在一起并计算元素数量,但它相当昂贵.有解决方法吗?
我有存储过程返回XML.XML不作为参数返回,而是作为SELECT的结果:
create procedure #xml_test
as
select 1 as a for xml raw
go
Run Code Online (Sandbox Code Playgroud)
我试图将这个XML放在一个变量中:
declare @xml as nvarchar(max)
Run Code Online (Sandbox Code Playgroud)
但我找不到怎么做.我最好的想法是INSERT INTO ... EXEC,但是我收到错误'INSERT语句中不允许使用FOR XML子句.':
create table #tmp(col1 nvarchar(max) not null)
insert into #tmp
exec #xml_test
Run Code Online (Sandbox Code Playgroud)
这种方法适用于通常的文本:
create procedure #text_test
as
select 'aaa' as a
go
insert into #tmp
exec #text_test
Run Code Online (Sandbox Code Playgroud)
我想知道以前有人遇到过这个问题吗?我在SQL Server 2005上