IF NOT EXISTS (SELECT 1 FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'DBO.PDV_VD_LINX_PROMO') AND TYPE IN (N'U'))
BEGIN
	CREATE TABLE DBO.PDV_VD_LINX_PROMO(
		CD_CTR					BIGINT IDENTITY (1,1),
		CD_EMP 					INT  ,
		CD_FILIAL 				INT  ,
		CD_CX 					INT  ,
		DT_VD 					DATETIME  ,
		NR_ECF 					INT  NULL,
		TIPO_CARTAO 			VARCHAR(25)COLLATE SQL_LATIN1_GENERAL_CP1_CI_AS CONSTRAINT DF_PDV_VD_LINX_PROMO_TIPO_CARTAO DEFAULT(''),
		NR_CARTAO_LINX_PROMO 	VARCHAR(25)COLLATE SQL_LATIN1_GENERAL_CP1_CI_AS   ,
		VLR_LINX_PROMO 			MONEY ,
		CONSTRAINT PK_PDV_VD_LINX_PROMO PRIMARY KEY (CD_CTR, CD_EMP)
	)
END
GO
IF NOT EXISTS (SELECT TOP 1 * FROM PDV_VD_LINX_PROMO )
BEGIN 
	DROP TABLE PDV_VD_LINX_PROMO
END 
GO 
IF NOT EXISTS (SELECT 1 FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'DBO.PDV_VD_LINX_PROMO') AND TYPE IN (N'U'))
BEGIN
	CREATE TABLE DBO.PDV_VD_LINX_PROMO(
		CD_CTR					BIGINT IDENTITY (1,1),
		CD_EMP 					INT  ,
		CD_FILIAL 				INT  ,
		CD_CX 					INT  ,
		DT_VD 					DATETIME  ,
		NR_ECF 					INT  NULL,
		TIPO_CARTAO 			VARCHAR(25)COLLATE SQL_LATIN1_GENERAL_CP1_CI_AS CONSTRAINT DF_PDV_VD_LINX_PROMO_TIPO_CARTAO DEFAULT(''),
		NR_CARTAO_LINX_PROMO 	VARCHAR(25)COLLATE SQL_LATIN1_GENERAL_CP1_CI_AS   ,
		VLR_LINX_PROMO 			MONEY ,
		CONSTRAINT PK_PDV_VD_LINX_PROMO PRIMARY KEY (CD_CTR, CD_EMP)
	)
END