Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Gordon Saxby 1444 posts 1855 karma points
    Aug 09, 2016 @ 16:28
    Gordon Saxby
    0

    Copy Forms data from one DB to another

    I need to transfer the data collected by two Forms from the current database into a new database. The new database does not have any Forms data, however I need to keep the current record ID values - as they have been used as a key for returning visitors to open up their submitted data :-(

    I am assuming I will need to do this as a SQL script, to turn off identity insert, etc but I was just wondering if anyone had just happened to have done it already and had a ready prepared script!!

    Is all of the Forms data limited to the tables beginning with "UF"?

  • Mark 122 posts 255 karma points
    Aug 11, 2016 @ 15:28
    Mark
    0

    Can I add a me too to this.. It's something I know will be coming up in the near future for one of my sites..

    Gordon, if you figure it out and it's nice and easy, would be great to hear exactly what you needed to do :-)

    Cheers,

    Mark

  • Gordon Saxby 1444 posts 1855 karma points
    Aug 12, 2016 @ 10:40
    Gordon Saxby
    0

    Hi Mark, I have created an SQL script to copy the contents of specific tables.

        USE Umbraco74
    -- Copy Forms data from the current database (Umbraco72) into the new database (Umbraco74)
    
    -- UFRecords
    -- Allow insert of Identity values
    SET IDENTITY_INSERT UFRecords ON
    
    INSERT INTO UFRecords ([Id], [Form], [Created], [Updated], [CurrentPage], [UmbracoPageId], [IP], [MemberKey], [UniqueId], [State], [RecordData])
        SELECT [Id], [Form], [Created], [Updated], [CurrentPage], [UmbracoPageId], [IP], [MemberKey], [UniqueId], [State], [RecordData] 
        FROM Umbraco72.dbo.UFRecords
    
    SET IDENTITY_INSERT UFRecords OFF
    
    -- UFRecordFields
    INSERT INTO UFRecordFields ([Key], [FieldId], [Record], [Alias], [DataType])
        SELECT [Key], [FieldId], [Record], [Alias], [DataType]
        FROM Umbraco72.dbo.UFRecordFields
    
    -- UFRecordDataString
    SET IDENTITY_Insert UFRecordDataString ON
    
    INSERT INTO UFRecordDataString ([Id], [Key], [Value])
        SELECT [Id], [Key], [Value]
        FROM Umbraco72.dbo.UFRecordDataString
    
    SET IDENTITY_Insert UFRecordDataString OFF
    
    -- UFRecordDataString
    SET IDENTITY_Insert UFRecordDataLongString ON
    
    INSERT INTO UFRecordDataLongString ([Id], [Key], [Value])
        SELECT [Id], [Key], [Value]
        FROM Umbraco72.dbo.UFRecordDataLongString
    
    SET IDENTITY_Insert UFRecordDataLongString OFF
    

    There are other "UF" tables that you may also need to add, if they have any content in them.

    It goes without saying that you should make a backup of both databases before trying this script. Also, note that this works on the basis that there are NO existing records in the destination database. Finally, please note that although I have run this a few times, I have not done extensive testing to ensure nothing has gone wrong! (phew, end of the T&C's!!!)

  • Ayo Adesina 430 posts 1023 karma points
    Jun 29, 2020 @ 15:39
    Ayo Adesina
    0

    Could this work with Umbraco 8...

    Is there another way to do it the latest version?

Please Sign in or register to post replies

Write your reply to:

Draft