SQL查询:
SELECT id,mti,[24] AS nii,mid,tid,[63-D9] AS TxnType,[63-DB] AS batchStatus ,
[39] AS respondCode,[61] AS batchNumber, uploadStatus
FROM (SELECT e.id,m.capDateTime,mti,procCode,mid,tid,uploadStatus,txnDate,txnTime,fieldNumber,fieldData FROM dbo.iso_fields e
JOIN dbo.iso_main m ON e.id = m.id) a PIVOT (MAX(fieldData) FOR fieldNumber IN
([0],[1],[2],[3],[5],[6],[7],[8],[9],[10],[12],[13],[14],[15],[16],[17],[18],[19],[20], [21],[22],[23],[24],[25],[26],[27],[28],[29],[30],
[31],[32],[33],[34],[35],[36],[39],[40], [41],[42],[43],[44],[45],[46],[47],[48],[49],[50],[51],[52],[53],[54],[55],[56],[57],[58],[59],[60],
[61],[63],[64],[63-D9],[63-DB]))PIV
我试图更新表格,例如:
UPDATE PIV SET batchStatus = 'C'
SELECT id,mti,[24] AS nii,mid,tid,[63-D9] AS TxnType,[63-DB] AS batchStatus ,
[39] AS respondCode,[61] AS batchNumber, uploadStatus
FROM (SELECT e.id,m.capDateTime,mti,procCode,mid,tid,uploadStatus,txnDate,txnTime,fieldNumber,fieldData FROM dbo.iso_fields e
JOIN dbo.iso_main m ON e.id = m.id) a PIVOT (MAX(fieldData) FOR fieldNumber IN
([0],[1],[2],[3],[5],[6],[7],[8],[9],[10],[12],[13],[14],[15],[16],[17],[18],[19],[20], [21],[22],[23],[24],[25],[26],[27],[28],[29],[30],
[31],[32],[33],[34],[35],[36],[39],[40], [41],[42],[43],[44],[45],[46],[47],[48],[49],[50],[51],[52],[53],[54],[55],[56],[57],[58],[59],[60],
[61],[63],[64],[63-D9],[63-DB]))PIV
WHERE nii = '0000'
我很确定这不是正确的语法,而且在数据透视表的
中非常可怕答案 0 :(得分:0)
在查看您的查询后,您似乎正在更新PIVOT" PIV"这是不可能的。 Pivot仅与聚合条款有关。你无法更新它。
如果我正确理解您的问题,您想刷新PIVOT数据,如果这个假设是正确的,那么您需要更新您在PIVOT中使用的主表或使用临时表来反映更新的数据。