

IF OBJECT_ID('[RC_DEB_PAG]', 'U') IS NULL
BEGIN
    SET ANSI_NULLS ON
    SET QUOTED_IDENTIFIER ON


    CREATE TABLE [RC_DEB_PAG]
    (
        CD_CTR 		INT IDENTITY(1,1) NOT NULL, 
        CD_EMP		INT,
        CD_FILIAL	INT,
        CD_RC_DEB	INT,
        CD_ORC_PAG	INT,
        CD_TIPO_PAG	INT,
        VLR_PAG		REAL,
        VLR_TROCO	REAL,
        CONSTRAINT [PK_RC_DEB_PAG] PRIMARY KEY CLUSTERED ( [CD_CTR] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY]

    ALTER TABLE [RC_DEB_PAG] WITH CHECK ADD  CONSTRAINT [FK_RC_DEB_PAG_TELE_ORC_PAG] FOREIGN KEY([CD_ORC_PAG])REFERENCES [TELE_ORC_PAG] ([CD_ORC_PAG])
	ALTER TABLE [RC_DEB_PAG] CHECK CONSTRAINT [FK_RC_DEB_PAG_TELE_ORC_PAG]

    ALTER TABLE [RC_DEB_PAG] WITH CHECK ADD  CONSTRAINT [FK_RC_DEB_PAG_RC_DEB] FOREIGN KEY([CD_EMP],[CD_FILIAL], [CD_RC_DEB]) REFERENCES [RC_DEB] ([CD_EMP],[CD_FILIAL], [CD_RC_DEB])
	ALTER TABLE [RC_DEB_PAG] CHECK CONSTRAINT [FK_RC_DEB_PAG_RC_DEB]


END

