Files
DP44/DataPRO_sql/dbo.TestChannelSettings.Table.sql
2026-04-17 14:55:32 -04:00

51 lines
6.9 KiB
Transact-SQL
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
IF EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_TestChannelSettings_TestSetups]') AND parent_object_id = OBJECT_ID(N'[dbo].[TestChannelSettings]'))
ALTER TABLE [dbo].[TestChannelSettings] DROP CONSTRAINT [FK_TestChannelSettings_TestSetups]
GO
IF EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_TestChannelSettings_TestObjects]') AND parent_object_id = OBJECT_ID(N'[dbo].[TestChannelSettings]'))
ALTER TABLE [dbo].[TestChannelSettings] DROP CONSTRAINT [FK_TestChannelSettings_TestObjects]
GO
IF EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_TestChannelSettings_TemplateChannels]') AND parent_object_id = OBJECT_ID(N'[dbo].[TestChannelSettings]'))
ALTER TABLE [dbo].[TestChannelSettings] DROP CONSTRAINT [FK_TestChannelSettings_TemplateChannels]
GO
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[TestChannelSettings]') AND type in (N'U'))
DROP TABLE [dbo].[TestChannelSettings]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[TestChannelSettings]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[TestChannelSettings](
[TestSetupId] [int] NOT NULL,
[TestObjectId] [int] NOT NULL,
[TemplateChannelId] [int] NOT NULL,
[ChannelId] [nvarchar](255) NOT NULL,
[Setting] [nvarchar](255) NULL,
[SensorId] [int] NOT NULL,
[Disabled] [bit] NOT NULL
) ON [PRIMARY]
END
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_TestChannelSettings_TemplateChannels]') AND parent_object_id = OBJECT_ID(N'[dbo].[TestChannelSettings]'))
ALTER TABLE [dbo].[TestChannelSettings] WITH NOCHECK ADD CONSTRAINT [FK_TestChannelSettings_TemplateChannels] FOREIGN KEY([TemplateChannelId])
REFERENCES [dbo].[TemplateChannels] ([TemplateChannelId])
GO
IF EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_TestChannelSettings_TemplateChannels]') AND parent_object_id = OBJECT_ID(N'[dbo].[TestChannelSettings]'))
ALTER TABLE [dbo].[TestChannelSettings] CHECK CONSTRAINT [FK_TestChannelSettings_TemplateChannels]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_TestChannelSettings_TestObjects]') AND parent_object_id = OBJECT_ID(N'[dbo].[TestChannelSettings]'))
ALTER TABLE [dbo].[TestChannelSettings] WITH NOCHECK ADD CONSTRAINT [FK_TestChannelSettings_TestObjects] FOREIGN KEY([TestObjectId])
REFERENCES [dbo].[TestObjects] ([TestObjectId])
GO
IF EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_TestChannelSettings_TestObjects]') AND parent_object_id = OBJECT_ID(N'[dbo].[TestChannelSettings]'))
ALTER TABLE [dbo].[TestChannelSettings] CHECK CONSTRAINT [FK_TestChannelSettings_TestObjects]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_TestChannelSettings_TestSetups]') AND parent_object_id = OBJECT_ID(N'[dbo].[TestChannelSettings]'))
ALTER TABLE [dbo].[TestChannelSettings] WITH NOCHECK ADD CONSTRAINT [FK_TestChannelSettings_TestSetups] FOREIGN KEY([TestSetupId])
REFERENCES [dbo].[TestSetups] ([TestSetupId])
GO
IF EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_TestChannelSettings_TestSetups]') AND parent_object_id = OBJECT_ID(N'[dbo].[TestChannelSettings]'))
ALTER TABLE [dbo].[TestChannelSettings] CHECK CONSTRAINT [FK_TestChannelSettings_TestSetups]
GO