Tables [dbo].[XmlXtraStopMap]
Properties
PropertyValue
CollationSQL_Latin1_General_CP1_CI_AS
Row Count (~)0
Created10:03:28 AM Friday, December 7, 2018
Last Modified10:03:47 AM Friday, December 7, 2018
Columns
NameData TypeMax Length (Bytes)Allow NullsIdentity
Cluster Primary Key PK_XmlXtraStopMap: XmlXtraStopMapIDXmlXtraStopMapIDint4
No
1 - 1
Foreign Keys FK_XmlXtraStopMap_XtraStop: [dbo].[XtraStop].XtraStopFIDIndexes IX_XmlXtraStopMap_XtraStop_XmlSystem: XtraStopFID\XmlSystemFIDXtraStopFIDint4
No
Foreign Keys FK_XmlXtraStopMap_Orders: [dbo].[Orders].OrderFIDIndexes IX_XmlXtraStopMap_Orders_ExternalStopNumber_XmlSystem: OrderFID\ExternalStopNumber\XmlSystemFIDOrderFIDint4
No
Foreign Keys FK_XmlXtraStopMap_XmlSystem: [dbo].[XmlSystem].XmlSystemFIDIndexes IX_XmlXtraStopMap_Orders_ExternalStopNumber_XmlSystem: OrderFID\ExternalStopNumber\XmlSystemFIDIndexes IX_XmlXtraStopMap_XtraStop_XmlSystem: XtraStopFID\XmlSystemFIDXmlSystemFIDint4
No
Indexes IX_XmlXtraStopMap_Orders_ExternalStopNumber_XmlSystem: OrderFID\ExternalStopNumber\XmlSystemFIDExternalStopNumbervarchar(16)16
No
ExternalTripNumbervarchar(16)16
Yes
ExternalMoveNumbervarchar(16)16
Yes
Indexes Indexes
NameColumnsUnique
Cluster Primary Key PK_XmlXtraStopMap: XmlXtraStopMapIDPK_XmlXtraStopMapXmlXtraStopMapID
Yes
IX_XmlXtraStopMap_Orders_ExternalStopNumber_XmlSystemOrderFID, ExternalStopNumber, XmlSystemFID
Yes
IX_XmlXtraStopMap_XtraStop_XmlSystemXtraStopFID, XmlSystemFID
Yes
Triggers Triggers
NameANSI Nulls OnQuoted Identifier OnOn
XmlXtraStopMapDeleted
Yes
Yes
After Delete
Foreign Keys Foreign Keys
NameDeleteColumns
FK_XmlXtraStopMap_OrdersOrderFID->[dbo].[Orders].[PriKey]
FK_XmlXtraStopMap_XmlSystemXmlSystemFID->[dbo].[XmlSystem].[XmlSystemID]
FK_XmlXtraStopMap_XtraStopCascadeXtraStopFID->[dbo].[XtraStop].[PriKey]
Permissions
TypeActionOwning Principal
GrantDeleteMssExec
GrantInsertMssExec
GrantSelectMssExec
GrantUpdateMssExec
SQL Script
CREATE TABLE [dbo].[XmlXtraStopMap]
(
[XmlXtraStopMapID] [int] NOT NULL IDENTITY(1, 1),
[XtraStopFID] [int] NOT NULL,
[OrderFID] [int] NOT NULL,
[XmlSystemFID] [int] NOT NULL,
[ExternalStopNumber] [varchar] (16) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[ExternalTripNumber] [varchar] (16) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[ExternalMoveNumber] [varchar] (16) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
) ON [PRIMARY]
GO

create trigger [dbo].[XmlXtraStopMapDeleted] on [dbo].[XmlXtraStopMap]
for delete
as
    set nocount on
    insert into [XmlXtraStopDeletedMap]
    (
        [OrderFID],
        [XmlSystemFID],
        [ExternalStopNumber],
        [ExternalTripNumber],
        [ExternalMoveNumber]
    )
    select
        [OrderFID] = DELETED.OrderFID,
        [XmlSystemFID] = DELETED.[XmlSystemFID],
        [ExternalStopNumber] = DELETED.[ExternalStopNumber],
        [ExternalTripNumber] = DELETED.[ExternalTripNumber],
        [ExternalMoveNumber] = DELETED.[ExternalMoveNumber]
    from DELETED
    except
    select
        [OrderFID] = [XmlXtraStopDeletedMap].OrderFID,
        [XmlSystemFID] = DELETED.[XmlSystemFID],
        [ExternalStopNumber] = DELETED.[ExternalStopNumber],
        [ExternalTripNumber] = DELETED.[ExternalTripNumber],
        [ExternalMoveNumber] = DELETED.[ExternalMoveNumber]
    from [XmlXtraStopDeletedMap]
    inner join DELETED on
        [XmlXtraStopDeletedMap].[OrderFID] = DELETED.OrderFID and
        [XmlXtraStopDeletedMap].[XmlSystemFID] = DELETED.[XmlSystemFID] and
        [XmlXtraStopDeletedMap].[ExternalStopNumber] = DELETED.[ExternalStopNumber]
GO
ALTER TABLE [dbo].[XmlXtraStopMap] ADD CONSTRAINT [PK_XmlXtraStopMap] PRIMARY KEY CLUSTERED  ([XmlXtraStopMapID]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[XmlXtraStopMap] ADD CONSTRAINT [IX_XmlXtraStopMap_Orders_ExternalStopNumber_XmlSystem] UNIQUE NONCLUSTERED  ([OrderFID], [ExternalStopNumber], [XmlSystemFID]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[XmlXtraStopMap] ADD CONSTRAINT [IX_XmlXtraStopMap_XtraStop_XmlSystem] UNIQUE NONCLUSTERED  ([XtraStopFID], [XmlSystemFID]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[XmlXtraStopMap] ADD CONSTRAINT [FK_XmlXtraStopMap_Orders] FOREIGN KEY ([OrderFID]) REFERENCES [dbo].[Orders] ([PriKey])
GO
ALTER TABLE [dbo].[XmlXtraStopMap] ADD CONSTRAINT [FK_XmlXtraStopMap_XmlSystem] FOREIGN KEY ([XmlSystemFID]) REFERENCES [dbo].[XmlSystem] ([XmlSystemID])
GO
ALTER TABLE [dbo].[XmlXtraStopMap] ADD CONSTRAINT [FK_XmlXtraStopMap_XtraStop] FOREIGN KEY ([XtraStopFID]) REFERENCES [dbo].[XtraStop] ([PriKey]) ON DELETE CASCADE
GO
GRANT SELECT ON  [dbo].[XmlXtraStopMap] TO [MssExec]
GRANT INSERT ON  [dbo].[XmlXtraStopMap] TO [MssExec]
GRANT DELETE ON  [dbo].[XmlXtraStopMap] TO [MssExec]
GRANT UPDATE ON  [dbo].[XmlXtraStopMap] TO [MssExec]
GO
Uses