IF NOT EXISTS (SELECT 1 FROM SYS.tables where object_id = OBJECT_ID(N'LD0P0REPORTATTACHMENTDTO'))
BEGIN 
CREATE TABLE LD0P0REPORTATTACHMENTDTO
(
            ID INT NOT NULL,
			REPORTDTOREPORTID UNIQUEIDENTIFIER NOT NULL,
            NAME NVARCHAR(256) NULL,
            SIZE INT NOT NULL,
            CONTENT VARBINARY(MAX) NULL,
CONSTRAINT PK_LD0P0REPORTATTACHMENTDTO PRIMARY KEY CLUSTERED 
(
            ID ASC
))
END
;
IF EXISTS (SELECT 1 FROM SYS.VIEWS WHERE NAME='LD0V0REPORTATTACHMENTDTO')
BEGIN
DROP VIEW LD0V0REPORTATTACHMENTDTO
END
;
CREATE VIEW LD0V0REPORTATTACHMENTDTO AS SELECT * FROM LD0P0REPORTATTACHMENTDTO
;