我收到错误:
Msg 512,Level 16,State 1,Line 1
运行我的查询时。我知道冲突的位置:只是试图确定如何隔离相关列以解决错误。
特定列称为PARAMETER_SET.TEMPLATE_VERSION
。它有两个值。以下查询中的数据跨两个template_version
值复制,这导致512消息(即,商家,标题3,FID,UID,MID都被复制)。
注意:在创建第二个template_version
值并填充数据库之前,我能够成功运行下面的查询。
我的目标是查询输出只包含一个template_version的数据,这应解决我的512问题。
select
t.signature, rp.SIGNATURE as 'estate',
tp2.SIGNATURE as 'sub-estate1',
tp1.SIGNATURE as 'sub-estate2',
(select VALUE
from PARAMETER_VALUES pv
join PARAMETER_SET ps on ps.DATASET_ID = pv.DATASET_ID
where FIELD_ID = 'Merchant.1.RcptHdrLn1'
and ps.TERMINAL_ID = t.TERMINAL_ID) as 'Merchant1|RcptHdrLn1',
(select VALUE
from PARAMETER_VALUES pv
join PARAMETER_SET ps on ps.DATASET_ID = pv.DATASET_ID
where FIELD_ID = 'Merchant.1.RcptHdrLn2'
and ps.TERMINAL_ID = t.TERMINAL_ID) as 'Merchant1|RcptHdrLn2',
(select VALUE
from PARAMETER_VALUES pv
join PARAMETER_SET ps on ps.DATASET_ID = pv.DATASET_ID
where FIELD_ID = 'Merchant.1.Host0|Acq0|Mid'
and ps.TERMINAL_ID = t.TERMINAL_ID) as 'Merchant1|Host0|Acq0|Mid',
(select VALUE
from PARAMETER_VALUES pv
join PARAMETER_SET ps on ps.DATASET_ID = pv.DATASET_ID
where FIELD_ID = 'Merchant.1.Fid' and ps.TERMINAL_ID = t.TERMINAL_ID) as 'Merchant1|Fid',
(select VALUE
from PARAMETER_VALUES pv
join PARAMETER_SET ps on ps.DATASET_ID = pv.DATASET_ID
where FIELD_ID = 'Merchant.1.Uid' and ps.TERMINAL_ID = t.TERMINAL_ID) as 'Merchant1|Uid',
(select VALUE
from PARAMETER_VALUES pv
join PARAMETER_SET ps on ps.DATASET_ID = pv.DATASET_ID
where FIELD_ID = 'Header3' and ps.TERMINAL_ID = t.TERMINAL_ID) as 'Header3'
from
terminal t
join
terminal tp1 on t.PARENT_ID = tp1.TERMINAL_ID
join
terminal tp2 on tp1.PARENT_ID = tp2.TERMINAL_ID
join
terminal rp on tp2.PARENT_ID = rp.TERMINAL_ID
order by
estate, [sub-estate1], [sub-estate2]