 
IF NOT EXISTS (SELECT * FROM SYS.TABLES WHERE NAME = 'PDV_VD_ENDERECO')

BEGIN 
      CREATE TABLE PDV_VD_ENDERECO (
      	   CD_EMP			 INT  NOT NULL DEFAULT 0,
      	   CD_FILIAL		 INT  NOT NULL DEFAULT 0,
      	   CD_VD			 INT  NOT NULL DEFAULT 0,
      	   CD_CX			 INT  NOT NULL DEFAULT 0,
      	   CEP				 VARCHAR(50)   COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
      	   CD_MUNICIPIO_IBGE VARCHAR(50)   COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
      	   NR_NRO			 INT  NOT NULL DEFAULT 0,
      	   COMPLEMENTO		 VARCHAR(50)   COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
      	   END_CLI			 VARCHAR(300)  COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
      	   BAIRRO			 VARCHAR(50)   COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
      	   DS_CID			 VARCHAR(100)  COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
      	   UF				 VARCHAR(2)    COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
      	   CD_PAIS           INT  NOT NULL DEFAULT 1058,
      	   DS_PAIS           VARCHAR(50)   COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL DEFAULT 'BRASIL'
      	     );
      
      ALTER TABLE PDV_VD_ENDERECO ADD CONSTRAINT PK_PDV_VD_ENDERECO PRIMARY KEY (CD_EMP, CD_FILIAL, CD_VD, CD_CX);

END ; 
