• Perry Whittle - Thursday, March 23, 2017 6:47 AM

    SQL!$@w$0ME - Wednesday, March 15, 2017 6:07 AM

    Perry Whittle - Tuesday, March 14, 2017 11:09 AM

    SQL!$@w$0ME - Monday, March 13, 2017 4:19 PM

    Hello Folks,

    What is the best approach to refresh UAT table from Production. Tables have foreign key constraints and identity keys. Tables on Prod and UAT have the same structure. 
    Please list the detailed steps for this task.

    Many thanks!

    Use some code to do what has already been mentioned

  • Drop the FKs
  • Truncate the tables
  • Set IDENTITY_INSERT on for the destination table, if you're not worried about the id  values then skip this
  • Load the tables from production using select queries, a linked server would work here
  • Turn off the IDENTITY_INSERT if you switched it on
  • Create the FK constraint
  • Hi Perry, Should I disable all triggers before data load using linked server or export import and enable after the load?

    Generally, yes, you don't want triggers firing during the import but as mentioned it all depends.
    If you're importing all tables and the trigger is firing to update a table you're also importing to it could cause duplicates

    Thanks a lot