CREATE  INDEX TRVHTPrjCode ON VS4TDeliveryIN(TDCITPrjCode)
GO

CREATE  INDEX TRVHTPrjCode ON VS4TDeliveryOut(TDCOTPrjCode)
GO

ALTER TABLE VS4TDeliveryINMB ALTER COLUMN TDIMTIAPNo NVARCHAR (30) NOT NULL 
GO

ALTER TABLE VS4TDeliveryINMB ADD 
CONSTRAINT VS4TAPInvoiceVS4TDeliveryINMB FOREIGN KEY 
(
TDIMTIAPNo
) REFERENCES VS4TAPInvoice (
TIAPNo
) ON UPDATE CASCADE
GO

ALTER TABLE VS4TDeliveryINMB ALTER COLUMN TDIMTDCINo NVARCHAR (30) NOT NULL 
GO

ALTER TABLE VS4TDeliveryINMB ADD 
CONSTRAINT VS4TDeliveryINVS4TDeliveryINMB FOREIGN KEY 
(
TDIMTDCINo
) REFERENCES VS4TDeliveryIN (
TDCINo
) ON UPDATE CASCADE
GO

ALTER TABLE VS4TDelvieryOutMB ALTER COLUMN TDOMTIvoNo NVARCHAR (30) NOT NULL 
GO

ALTER TABLE VS4TDelvieryOutMB ADD 
CONSTRAINT VS4TARInvoiceVS4TDelvieryOutMB FOREIGN KEY 
(
TDOMTIvoNo
) REFERENCES VS4TARInvoice (
TIvoNo
) ON UPDATE CASCADE
GO

ALTER TABLE VS4TDelvieryOutMB ALTER COLUMN TDOMTDCONo NVARCHAR (30) NOT NULL 
GO

ALTER TABLE VS4TDelvieryOutMB ADD 
CONSTRAINT VS4TDeliveryOutVS4TDelvieryOutMB FOREIGN KEY 
(
TDOMTDCONo
) REFERENCES VS4TDeliveryOut (
TDCONo
) ON UPDATE CASCADE
GO



ALTER TABLE VS4TMPR ALTER COLUMN TMPRTBraCode NVARCHAR (30) NOT NULL 
GO

ALTER TABLE VS4TMPR ADD 
CONSTRAINT VS4TBranchVS4TMPR FOREIGN KEY 
(
TMPRTBraCode
) REFERENCES VS4TBranch (
TBraCode
) ON UPDATE CASCADE
GO

ALTER TABLE VS4TMPR ALTER COLUMN TMPRTDivCode NVARCHAR (30) NOT NULL 
GO


ALTER TABLE VS4TMPRMB ALTER COLUMN TMPMTMPRNo NVARCHAR (30) NOT NULL 
GO

ALTER TABLE VS4TMPRMB ADD 
CONSTRAINT VS4TMPRVS4TMPRMB FOREIGN KEY 
(
TMPMTMPRNo
) REFERENCES VS4TMPR (
TMPRNo
) ON UPDATE CASCADE
GO

ALTER TABLE VS4TMPRMB ALTER COLUMN TMPMTPstCode NVARCHAR (30) NOT NULL 
GO

ALTER TABLE VS4TMPRMB ADD 
CONSTRAINT VS4TPositionVS4TMPRMB FOREIGN KEY 
(
TMPMTPstCode
) REFERENCES VS4TPosition (
TPstCode
) ON UPDATE CASCADE
GO
