IF NOT EXISTS(SELECT 1 FROM INFORMATION_SCHEMA.TABLES
				WHERE TABLE_NAME=N'RC_ADM_CARTAO_MOV_LOTE_PDV_CUPOM_NAO_FISCAL')
BEGIN			
	SET ANSI_NULLS ON
	SET QUOTED_IDENTIFIER ON
	CREATE TABLE [dbo].[RC_ADM_CARTAO_MOV_LOTE_PDV_CUPOM_NAO_FISCAL](
		[CD_CTR_LOTE] [int] NOT NULL CONSTRAINT [DF_RC_ADM_CARTAO_MOV_LOTE_PDV_CUPOM_NAO_FISCAL_CD_CTR_LOTE]  DEFAULT ((0)),
		[CD_EMP] [int] NOT NULL CONSTRAINT [DF_RC_ADM_CARTAO_MOV_LOTE_PDV_CUPOM_NAO_FISCAL_CD_EMP]  DEFAULT ((0)),
		[CD_FILIAL] [int] NOT NULL CONSTRAINT [DF_RC_ADM_CARTAO_MOV_LOTE_PDV_CUPOM_NAO_FISCAL_CD_FILIAL]  DEFAULT ((0)),
		[CD_CTR_CUPOM] [int] NOT NULL CONSTRAINT [DF_RC_ADM_CARTAO_MOV_LOTE_PDV_CUPOM_NAO_FISCAL_CD_VD]  DEFAULT ((0)),
		[CD_CTR] [int] NOT NULL CONSTRAINT [DF_RC_ADM_CARTAO_MOV_LOTE_PDV_CUPOM_NAO_FISCAL_CD_CTR]  DEFAULT ((0)),
	 CONSTRAINT [PK_RC_ADM_CARTAO_MOV_LOTE_PDV_CUPOM_NAO_FISCAL] PRIMARY KEY CLUSTERED 
	(
		[CD_CTR_LOTE] ASC,
		[CD_EMP] ASC,
		[CD_FILIAL] ASC,
		[CD_CTR_CUPOM] ASC,
		[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 [dbo].[RC_ADM_CARTAO_MOV_LOTE_PDV_CUPOM_NAO_FISCAL]  WITH CHECK 
		ADD  CONSTRAINT [FK_RC_ADM_CARTAO_MOV_LOTE_PDV_CUPOM_NAO_FISCAL_PDV_CUPOM_NAO_FISCAL_TEF] FOREIGN KEY([CD_EMP], [CD_FILIAL], [CD_CTR_CUPOM], [CD_CTR])
	REFERENCES [dbo].[PDV_CUPOM_NAO_FISCAL_TEF] ([CD_EMP], [CD_FILIAL], [CD_CTR],[CD_RECTO_TEF])
	ALTER TABLE [dbo].[RC_ADM_CARTAO_MOV_LOTE_PDV_CUPOM_NAO_FISCAL] CHECK CONSTRAINT [FK_RC_ADM_CARTAO_MOV_LOTE_PDV_CUPOM_NAO_FISCAL_PDV_CUPOM_NAO_FISCAL_TEF]
	ALTER TABLE [dbo].[RC_ADM_CARTAO_MOV_LOTE_PDV_CUPOM_NAO_FISCAL]  WITH CHECK 
		ADD  CONSTRAINT [FK_RC_ADM_CARTAO_MOV_LOTE_PDV_CUPOM_NAO_FISCAL_RC_ADM_CARTAO_MOV_LOTE] FOREIGN KEY([CD_CTR_LOTE])
	REFERENCES [dbo].[RC_ADM_CARTAO_MOV_LOTE] ([CD_CTR_LOTE])
	ON UPDATE CASCADE
	ALTER TABLE [dbo].[RC_ADM_CARTAO_MOV_LOTE_PDV_CUPOM_NAO_FISCAL] CHECK CONSTRAINT [FK_RC_ADM_CARTAO_MOV_LOTE_PDV_CUPOM_NAO_FISCAL_RC_ADM_CARTAO_MOV_LOTE]
END