Attachment copy over

BuketP
New Contributor

Hi, 

Is there anyone who succeded copying attachment files one period to another period ? There is a getdataattachment function, however I don´t see setdataattachment. 

Thanks in advance 

Buket

3 REPLIES 3

RobbSalzmann
Valued Contributor

Hi @BuketP, the information is in the DataAttachment Table.  It looks like you could write a query to do this, get the records with the attachments you want to copy, change the value in the time column and insert.  That should do it.

RobbSalzmann_0-1708009438418.png

 

RobbSalzmann
Valued Contributor

Here's an example that would copy all the attachments in Jan 2011 to Feb 2011:

INSERT INTO DataAttachment (
    [UniqueID],
    [Cube],
    [Entity],
    [Parent],
    [Cons],
    [Scenario],
    [Time],
    [Account],
    [Flow],
    [Origin],
    [IC],
    [UD1],
    [UD2],
    [UD3],
    [UD4],
    [UD5],
    [UD6],
    [UD7],
    [UD8],
    [Title],
    [AttachmentType],
    [CreatedUserName],
    [CreatedTimestamp],
    [LastEditedUserName],
    [LastEditedTimestamp],
    [Text],
    [FileName],
    [FileBytes]
)
SELECT
    NEWID() AS [UniqueID], 
    [Cube],
    [Entity],
    [Parent],
    [Cons],
    [Scenario],
    '2011M2' AS [Time], -- Set Time to whatever period you want
    [Account],
    [Flow],
    [Origin],
    [IC],
    [UD1],
    [UD2],
    [UD3],
    [UD4],
    [UD5],
    [UD6],
    [UD7],
    [UD8],
    [Title],
    [AttachmentType],
    [CreatedUserName],
    [CreatedTimestamp],
    [LastEditedUserName],
    [LastEditedTimestamp],
    [Text],
    [FileName],
    [FileBytes]
FROM
    DataAttachment
WHERE
    [Time] = '2011M1';

 

Thank you RobbSalzmann, 

I will give it a try.

BR

Buket

Br

Buket