Quantcast
Channel: StackExchange Replication Questions
Viewing all articles
Browse latest Browse all 17268

Is it a good idea to disable lock escalation while adding new calculated columns to a table?

$
0
0

Having in mind that I can add computed columns to the subscription tables according to this link:

SQL Server : Transactional Replication Computed Column

Is it a good idea to disable lock escalation while adding new calculated columns to a table?

like in the example below, the table has over 40 million records, I don't want to stop replication, and yet, I want to add this new field, which later will be part of an index (or filtered index).

BEGIN TRY

        BEGIN TRANSACTION t_01

        SELECT @@TRANCOUNT

        SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED

        ALTER TABLE dbo.tblBGiftVoucherItem SET (LOCK_ESCALATION=DISABLE)

        alter table dbo.tblBGiftVoucherItem
         add isUsGift AS CAST (( isnull(CASE WHEN sintMarketID = 2
                                        AND strType = 'CARD'
                                        AND strTier1 LIKE 'GG%' THEN 1 ELSE 0 END,0)) AS BIT)
        persisted

        ALTER TABLE dbo.tblBGiftVoucherItem  SET (LOCK_ESCALATION = AUTO)

        SELECT @@TRANCOUNT
        COMMIT TRANSACTION 


END TRY
BEGIN CATCH

    DECLARE @ErrorMessage NVARCHAR(4000);
    DECLARE @ErrorSeverity INT;
    DECLARE @ErrorState INT;

    WHILE @@TRANCOUNT > 0
         ROLLBACK TRANSACTION

    SELECT 
        @ErrorMessage = ERROR_MESSAGE(),
        @ErrorSeverity = ERROR_SEVERITY(),
        @ErrorState = ERROR_STATE();

    RAISERROR (@ErrorMessage, -- Message text.
               @ErrorSeverity, -- Severity.
               @ErrorState -- State.
               );
END CATCH

GO
-----------
        --alter table dbo.tblBGiftVoucherItem
        --DROP COLUMN isUsGift
        --GO

SP_HELP 'dbo.tblBGiftVoucherItem'

Viewing all articles
Browse latest Browse all 17268

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>