Donate

Cannot Delete Rows From A Temporal History Table In SQL Server

Given that you'll have to delete records from an SQL server history table, you might come across with the issue as mentioned in the title of the post. After doing some research and experiments, there are three steps to delete records from a temporal history table.
a. First is to remove the main table's System Versioning option.
ALTER TABLE [dbo].[tblParts] SET ( SYSTEM_VERSIONING = OFF )
b. Next is to delete the records of the temporal history table.
Delete from dbo.tblPartsHistory WITH (TABLOCKX);
c. Then Set again the system versioning and history table of the main table.
ALTER TABLE [dbo].[tblParts] SET ( SYSTEM_VERSIONING = ON (HISTORY_TABLE = [dbo].[tblPartsHistory]))   


Solved.. :-)

Comments

Donate

Popular Posts From This Blog

WPF CRUD Application Using DataGrid, MVVM Pattern, Entity Framework, And C#.NET

How To Insert Or Add Emojis In Microsoft Teams Status Message

TypeScript Error Or Bug: The term 'tsc' is not recognized as the name of a cmdlet, function, script file, or operable program.