sql 删除 xml 时出错
sql error on for xml removal
您好,我们有一个遗留代码,我们正在尝试修改并试图摆脱它 "for XML"。当前代码如下
Select
a.columnidfk as columnid,
tvs.columnversion as columnversion,
a.newcolumnId as newcolumnid,
(Select
at.columnTrackingId as columntrackingid,
at.newcolumnIdFk as newcolumnid,
at.IDBSIdFk as idbid,
i.Name as iname,
IsNull(convert(varchar,at.colidbdate,101),'') as colidbdate,
IsNull(convert(varchar,at.colidbdate2,101),'') as colidbdate2,
IsNull(at.colReason, '') as colReason,
IsNull(d.DispositionText, '') as DispositionText,
at.status as status
From columnTracking at
Left Outer Join LkIDBs i on at.IDBSIdFk = i.IDBSId
left outer join LkDisposition d On at.[colDecisionIdFk] = d.DispositionId
Where at.status in('Active','Inactive') and at.newcolumnIdFk = a.newcolumnId and (i.status in ('Active','Inactive') OR i.status is null) and (d.status='Active' or d.status is null)
for Xml path('columntracking'), type)
From tablecolumns a
Left Outer Join columnVersions tvs on a.columnversionidfk = tvs.columnversionid Where
a.columnVersionIdFk in
(Select columnVersionId From columnVersions tv
Inner Join tabcolumns t On tv.colIdFk = t.colId
Where t.TicketNo = @TicketNo )
order by a.TicketVersionIdFk , a.assessmentid
For Xml path('columntab'), Root('columns')
当我删除“for Xml 路径('columntracking')时,键入”和“For Xml path('columntab'),Root('columns')" 我收到以下错误
Only one expression can be specified in the select list when the subquery is not introduced with EXISTS.
请指教!
我相信我通过加入(第一个 xml 输出)
得到了想要的 table
Select
a.columnidfk as columnid,
tvs.columnversion as columnversion,
a.newcolumnId as newcolumnid,
att.columntrackingid,
att.newcolumnid,
att.idbid,
att.iname
From tablecolumns a
Left Outer Join columnVersions tvs on a.columnversionidfk = tvs.columnversionid Where
left outer join (
Select
at.columnTrackingId as columntrackingid,
at.newcolumnIdFk as newcolumnid,
at.IDBSIdFk as idbid,
i.Name as iname,
IsNull(convert(varchar,at.colidbdate,101),'') as colidbdate,
IsNull(convert(varchar,at.colidbdate2,101),'') as colidbdate2,
IsNull(at.colReason, '') as colReason,
IsNull(d.DispositionText, '') as DispositionText,
at.status as status
From columnTracking at
Left Outer Join LkIDBs i on at.IDBSIdFk = i.IDBSId
left outer join LkDisposition d On at.[colDecisionIdFk] = d.DispositionId
Where at.status in('Active','Inactive') and (i.status in ('Active','Inactive') OR i.status is null) and (d.status='Active' or d.status is null)
) att on att.newcolumnid = a.newcolumnId
and a.columnVersionIdFk in
(Select columnVersionId From columnVersions tv
Inner Join tabcolumns t On tv.colIdFk = t.colId
Where t.TicketNo = @TicketNo )
您好,我们有一个遗留代码,我们正在尝试修改并试图摆脱它 "for XML"。当前代码如下
Select
a.columnidfk as columnid,
tvs.columnversion as columnversion,
a.newcolumnId as newcolumnid,
(Select
at.columnTrackingId as columntrackingid,
at.newcolumnIdFk as newcolumnid,
at.IDBSIdFk as idbid,
i.Name as iname,
IsNull(convert(varchar,at.colidbdate,101),'') as colidbdate,
IsNull(convert(varchar,at.colidbdate2,101),'') as colidbdate2,
IsNull(at.colReason, '') as colReason,
IsNull(d.DispositionText, '') as DispositionText,
at.status as status
From columnTracking at
Left Outer Join LkIDBs i on at.IDBSIdFk = i.IDBSId
left outer join LkDisposition d On at.[colDecisionIdFk] = d.DispositionId
Where at.status in('Active','Inactive') and at.newcolumnIdFk = a.newcolumnId and (i.status in ('Active','Inactive') OR i.status is null) and (d.status='Active' or d.status is null)
for Xml path('columntracking'), type)
From tablecolumns a
Left Outer Join columnVersions tvs on a.columnversionidfk = tvs.columnversionid Where
a.columnVersionIdFk in
(Select columnVersionId From columnVersions tv
Inner Join tabcolumns t On tv.colIdFk = t.colId
Where t.TicketNo = @TicketNo )
order by a.TicketVersionIdFk , a.assessmentid
For Xml path('columntab'), Root('columns')
当我删除“for Xml 路径('columntracking')时,键入”和“For Xml path('columntab'),Root('columns')" 我收到以下错误
Only one expression can be specified in the select list when the subquery is not introduced with EXISTS.
请指教!
我相信我通过加入(第一个 xml 输出)
得到了想要的 tableSelect
a.columnidfk as columnid,
tvs.columnversion as columnversion,
a.newcolumnId as newcolumnid,
att.columntrackingid,
att.newcolumnid,
att.idbid,
att.iname
From tablecolumns a
Left Outer Join columnVersions tvs on a.columnversionidfk = tvs.columnversionid Where
left outer join (
Select
at.columnTrackingId as columntrackingid,
at.newcolumnIdFk as newcolumnid,
at.IDBSIdFk as idbid,
i.Name as iname,
IsNull(convert(varchar,at.colidbdate,101),'') as colidbdate,
IsNull(convert(varchar,at.colidbdate2,101),'') as colidbdate2,
IsNull(at.colReason, '') as colReason,
IsNull(d.DispositionText, '') as DispositionText,
at.status as status
From columnTracking at
Left Outer Join LkIDBs i on at.IDBSIdFk = i.IDBSId
left outer join LkDisposition d On at.[colDecisionIdFk] = d.DispositionId
Where at.status in('Active','Inactive') and (i.status in ('Active','Inactive') OR i.status is null) and (d.status='Active' or d.status is null)
) att on att.newcolumnid = a.newcolumnId
and a.columnVersionIdFk in
(Select columnVersionId From columnVersions tv
Inner Join tabcolumns t On tv.colIdFk = t.colId
Where t.TicketNo = @TicketNo )