Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Stopping System-Versioning on a System-Versioned Temporal Table in SQL Server 2016?

I have a table that has system versioning (temporal table), but I can not see a design environment visually. I do it because I can see the SYSTEM_VERSIONING clause has been used. I would like to have temporarily Stop and then enable it. Who can advise me?

like image 738
Aiyoub Avatar asked May 04 '17 10:05

Aiyoub


2 Answers

My problem was solved when i using following query:

-- SET SYSTEM_VERSIONING TO OFF
ALTER TABLE [dbo].[MyTable]
SET (SYSTEM_VERSIONING = OFF)
GO

** Do what ever you want to **

-- SET SYSTEM_VERSIONING TO ON
ALTER TABLE [dbo].[MyTable]
SET 
    (SYSTEM_VERSIONING = ON (HISTORY_TABLE = [dbo].[MyTable_Archive] , DATA_CONSISTENCY_CHECK = ON ))
GO
like image 107
Aiyoub Avatar answered Oct 13 '22 09:10

Aiyoub


ALTER TABLE dbo.MyTable SET (SYSTEM_VERSIONING = OFF);   

** Do what ever you want to **

ALTER TABLE dbo.MyTable SET (SYSTEM_VERSIONING = ON);   

See this Microsoft article for more info

like image 25
sarin Avatar answered Oct 13 '22 10:10

sarin