NucelarMonitor/SQLServer/NucelarMonitor.server.01.remove.server.sql

45 lines
2.3 KiB
Transact-SQL

if (select top 1 0 from sys.databases where name = 'NucelarMonitor') is null create database NucelarMonitor collate Latin1_General_100_CI_AS_SC_UTF8
go
use NucelarMonitor
if object_id(N'dbo.tables_drop', N'P') is not null drop procedure dbo.tables_drop
go
create procedure dbo.tables_drop as begin
set nocount on
-- Level Plains.
if object_id(N'dbo.MachineInterfacesTrafficPlain', N'U') is not null drop table dbo.MachineInterfacesTrafficPlain
if object_id(N'dbo.MachineInterfacesPlain', N'U') is not null drop table dbo.MachineInterfacesPlain
if object_id(N'dbo.MachineDisksPlain', N'U') is not null drop table dbo.MachineDisksPlain
if object_id(N'dbo.MachinePlain', N'U') is not null drop table dbo.MachinePlain
-- Level 2.
if object_id(N'dbo.MachineInterfacesData', N'U') is not null drop table dbo.MachineInterfacesData
if object_id(N'dbo.MachineInterfacesTraffic', N'U') is not null drop table dbo.MachineInterfacesTraffic
if object_id(N'dbo.MachineDisksSpace', N'U') is not null drop table dbo.MachineDisksSpace
if object_id(N'dbo.Exceptions', N'U') is not null drop table dbo.Exceptions
-- Level 1.
if object_id(N'dbo.MachineInterfaces', N'U') is not null drop table dbo.MachineInterfaces
if object_id(N'dbo.MachineDisks', N'U') is not null drop table dbo.MachineDisks
if object_id(N'dbo.MachineRAM', N'U') is not null drop table dbo.MachineRAM
if object_id(N'dbo.MachineCPU', N'U') is not null drop table dbo.MachineCPU
if object_id(N'dbo.Procedures', N'U') is not null drop table dbo.Procedures
-- Level 0.
if object_id(N'dbo.CandlesTimes', N'U') is not null drop table dbo.CandlesTimes
if object_id(N'dbo.Types', N'U') is not null drop table dbo.Types
if object_id(N'dbo.Interfaces', N'U') is not null drop table dbo.Interfaces
if object_id(N'dbo.Disks', N'U') is not null drop table dbo.Disks
if object_id(N'dbo.Hostnames', N'U') is not null drop table dbo.Hostnames
if object_id(N'dbo.Domains', N'U') is not null drop table dbo.Domains
if object_id(N'dbo.Machines', N'U') is not null drop table dbo.Machines
if object_id(N'dbo.Databases', N'U') is not null drop table dbo.Databases
if object_id(N'dbo.Messages', N'U') is not null drop table dbo.Messages
if object_id(N'dbo.BigData', N'U') is not null drop table dbo.BigData
end
go
-- execute dbo.tables_drop