-
Notifications
You must be signed in to change notification settings - Fork 36
/
Copy path99-cleanup.sql
43 lines (38 loc) · 1.18 KB
/
99-cleanup.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
if (objectpropertyex(object_id('dbo.Phone'), N'TableTemporalType') = 2)
alter table dbo.Phone set ( system_versioning = off )
go
if (objectpropertyex(object_id('dbo.Address'), N'TableTemporalType') = 2)
alter table dbo.[Address] set ( system_versioning = off )
go
if (objectpropertyex(object_id('dbo.OrderInfo'), N'TableTemporalType') = 2)
alter table dbo.OrderInfo set ( system_versioning = off )
go
if (objectpropertyex(object_id('dbo.Customer'), N'TableTemporalType') = 2)
alter table dbo.Customer set ( system_versioning = off )
go
drop table if exists dbo.Phone;
drop table if exists dbo.PhoneHistory;
go
drop table if exists dbo.[Address];
drop table if exists dbo.[AddressHistory];
go
drop view if exists dbo.DenormalizedTemporalView;
go
drop table if exists dbo.Customer
drop table if exists dbo.CustomerHistory
go
drop table if exists dbo.OrderInfo
drop table if exists dbo.OrderInfoHistory
go
declare @cmd nvarchar(max);
declare c cursor fast_forward for
select 'DROP TABLE dbo.' + quotename([name]) from sys.tables where [name] like 'MSSQL_Temporal%';
open c;
fetch next from c into @cmd
while (@@FETCH_STATUS = 0)
begin
exec(@cmd);
fetch next from c into @cmd;
end;
close c;
deallocate c;