I am trying to create a unit test on a procedure which touches a non-clustered columnstore table.
I create a fake table and then tried both dropping and disabling the CStore index before inserting test data but when I try to run the test, it always errors out saying "INSERT statement failed because data cannot be updated in a table that has a nonclustered columnstore index. Consider disabling the columnstore index before issuing the INSERT statement, and then rebuilding the columnstore index after INSERT has completed"
This is the concerned code snippet within the tsqlt procedure
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
GO
after eachALTER
andINSERT
statement. This is just a wild guess on my part though. – TT.