我正在尝试对涉及非聚集列存储表的过程创建单元测试。
我创建了一个假表,然后在插入测试数据之前尝试同时删除和禁用 CStore 索引,但是当我尝试运行测试时,它总是错误提示“INSERT 语句失败,因为无法在具有非聚集列存储的表中更新数据索引。考虑在发出 INSERT 语句之前禁用列存储索引,然后在 INSERT 完成后重建列存储索引“
这是 tsqlt 过程中相关的代码片段
EXEC [tSQLt].[FakeTable] @TableName = N'CommonDM.AccountBalances';
ALTER INDEX [IX_CS_FinanceDM_AccountBalances] ON [CommonDM].[AccountBalances] DISABLE
INSERT INTO commondm.AccountBalances
( MK_DatesID_TradeDate ,
MK_CurrenciesID_CurrencyCode ,
MK_UCRAccountsID_AccountID ,
EndOfDayAccountBalanceEUR ,
ClosingRateEURDKK ,
ClosingRateEURAC ,
DW_BatchID ,
EndOfDayAccountBalanceAC ,
RevaluationDKK ,
RevaluationEUR ,
MK_BusinessLinesID_BusinessLineID ,
MK_UCRCounterpartsID_CounterpartID
)
VALUES ( 20150325 , -- MK_DatesID_TradeDate - int
3 , -- MK_CurrenciesID_CurrencyCode - int
25891201 , -- MK_UCRAccountsID_AccountID - int
-3577.82776605942, -- EndOfDayAccountBalanceEUR - float
7.46875 , -- ClosingRateEURDKK - float
4.02910395425365 , -- ClosingRateEURAC - float
3152289, -- DW_BatchID - int
-14415.4399998685 , -- EndOfDayAccountBalanceAC - float
88.6549559991928 , -- RevaluationDKK - float
14.8043530611986 , -- RevaluationEUR - float
2 , -- MK_BusinessLinesID_BusinessLineID - int
31512216 -- MK_UCRCounterpartsID_CounterpartID - int
)
ALTER INDEX [IX_CS_FinanceDM_AccountBalances] ON [CommonDM].[AccountBalances] REBUILD