IF ((SELECT COUNT(*) FROM SYS.COLUMNS WHERE OBJECT_ID = OBJECT_ID('DSYNC_OCORRENCIAS') AND NAME LIKE 'SOLUCAO') != 0)
BEGIN
	DROP TABLE DSYNC_OCORRENCIAS
END
--//
IF OBJECT_ID('DSYNC_OCORRENCIAS') IS NULL
BEGIN
CREATE TABLE DBO.DSYNC_OCORRENCIAS
	(
	ID BIGINT IDENTITY(1,1) NOT NULL,
	CD_FILIAL INT NOT NULL,
	CD_USU INT NULL,
	DT_OCORRENCIA DATETIME NOT NULL,
	DT_MOV DATETIME NULL,
	OCORRENCIA NTEXT NOT NULL,
	RESOLVIDO INT NOT NULL,
        STACKTRACE NTEXT NOT NULL
	)  ON [PRIMARY]
	 TEXTIMAGE_ON [PRIMARY]
ALTER TABLE DBO.DSYNC_OCORRENCIAS ADD CONSTRAINT PK_DSYNC_OCORRENCIAS PRIMARY KEY CLUSTERED ( ID ) WITH ( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
CREATE NONCLUSTERED INDEX IX_DSYNC_OCORRENCIAS ON DBO.DSYNC_OCORRENCIAS ( ID ) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
END