Курсовая работа: Автоматизированная система бронирования авиабилетов
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.triggers WHERE object_id = OBJECT_ID(N'[dbo].[TR_Flights_Delete]'))
EXEC dbo.sp_executesql @statement = N'CREATE TRIGGER [dbo].[TR_Flights_Delete] ON [dbo].[Flights] INSTEAD OF DELETE
AS
DELETE FROM Orders
WHERE Orders.FlightID= (SELECT top(1) deleted.FlightID FROM deleted)
DELETE FROM Flights
WHERE Flights.FlightID= (SELECT top(1) deleted.FlightID FROM deleted)
RETURN'
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].[Orders]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[Orders](
[OrderID] [int] IDENTITY(1,1) NOT NULL,
[CreditCard] [varchar](16) NULL,
[Number1cl] [int] NULL,
[Number2cl] [int] NULL,
[UserID] [int] NULL,
[FlightID] [int] NULL,
CONSTRAINT [PK_Orders] PRIMARY KEY CLUSTERED
(
[OrderID] ASC