IF NOT EXISTS (SELECT *
                 FROM INFORMATION_SCHEMA.TABLES 
				WHERE TABLE_NAME = 'PDV_VD_PDV_NSU_QR_LINX'  
			   )
BEGIN  
     CREATE TABLE PDV_VD_PDV_NSU_QR_LINX (
	      CD_EMP       INT NOT NULL, 
		  CD_FILIAL    INT NOT NULL,  
		  CD_VD        INT NOT NULL, 
		  CD_CTR_ID    INT NOT NULL  
         );
		
	 ALTER TABLE PDV_VD_PDV_NSU_QR_LINX ADD CONSTRAINT PK_PDV_VD_PDV_NSU_QR_LINX PRIMARY KEY (CD_EMP,CD_FILIAL,CD_VD,CD_CTR_ID);
     ALTER TABLE PDV_VD_PDV_NSU_QR_LINX ADD CONSTRAINT FK_PDV_VD_PDV_NSU_QR_LINX_PDV_NSU_QR_LINX_CD_CTR_ID  FOREIGN KEY (CD_CTR_ID)  REFERENCES PDV_NSU_QR_LINX (CD_CTR_ID);
	 ALTER TABLE PDV_VD_PDV_NSU_QR_LINX ADD CONSTRAINT FK_PDV_VD_PDV_NSU_QR_LINX_PDV_NSU_QR_LINX_CD_EMP_CD_FILIAL_CD_VD FOREIGN KEY (CD_VD,CD_FILIAL,CD_EMP)  REFERENCES PDV_VD (CD_VD,CD_FILIAL,CD_EMP) 
END;