IF NOT EXISTS (SELECT * FROM sysobjects WHERE name = 'EST_RPS_NFSE_CANCEL' and xtype = 'U') 
BEGIN 
CREATE TABLE [dbo].[EST_RPS_NFSE_CANCEL](
	[CD_EMP] [int] NOT NULL,
	[CD_FILIAL] [int] NOT NULL,
	[RPS_ID] [bigint] NOT NULL,
 CONSTRAINT [PK_EST_RPS_NFSE_CANCEL] PRIMARY KEY CLUSTERED 
(
	[CD_EMP] ASC,
	[CD_FILIAL] ASC,
	[RPS_ID] 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 [dbo].[EST_RPS_NFSE_CANCEL]  WITH CHECK ADD  CONSTRAINT [FK_EST_RPS_NFSE_CANCEL_EST_RPS] FOREIGN KEY([RPS_ID])
REFERENCES [dbo].[EST_RPS] ([ID]);


ALTER TABLE [dbo].[EST_RPS_NFSE_CANCEL] CHECK CONSTRAINT [FK_EST_RPS_NFSE_CANCEL_EST_RPS]
END