نحوه حذف Temporal Tables

برای حذف جداول Temporal از دیتابیس‌های SQL از قطعه کد زیر استفاده نمایید:

DECLARE @temporalTable VARCHAR(MAX), @historyTable VARCHAR(MAX);

SET  @temporalTable = 'SecurityUser';

/* Find the history table */
SELECT @historyTable = OBJECT_NAME(history_table_id) 
    FROM sys.tables WHERE name = @temporalTable;
 
/* If yes alter the current table and switch off system versioning */
EXEC('ALTER TABLE [Core].[' + @temporalTable + '] SET (SYSTEM_VERSIONING = OFF)');
 
/* Drop the current table */
EXEC('DROP TABLE [Core].[' + @temporalTable + ']');
 
/* Drop the history table */
EXEC('DROP TABLE [Core].[' + @historyTable + ']');