Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. Transfer data between databases

Transfer data between databases

Scheduled Pinned Locked Moved Database
databasequestionsql-serversysadminhelp
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    Gulfraz Khan
    wrote on last edited by
    #1

    I have two SQL server databases on the same server. The table structure is same except for few. I want to move some records from different tables one database to another. What is the best way to do it? create a DTS package, but I don't know how it supports 'Begin Tran' and the 'Execute SQL Task' in the DTS does not take any parameter (i.e. global variables) in the update and delete statements. If I create a Stored procedure and use the 'Begin Tran' and 'Commit' statement in the procedure. It also does not work for me since the stored procedure keeps on executing the statements that are followed even if any error occurs (i.e. primary key violation etc.). How do I make sure that the statements in the stored procedure are rolled back or procedure exits when any error occurs in it. Thank you for helping me.

    E 1 Reply Last reply
    0
    • G Gulfraz Khan

      I have two SQL server databases on the same server. The table structure is same except for few. I want to move some records from different tables one database to another. What is the best way to do it? create a DTS package, but I don't know how it supports 'Begin Tran' and the 'Execute SQL Task' in the DTS does not take any parameter (i.e. global variables) in the update and delete statements. If I create a Stored procedure and use the 'Begin Tran' and 'Commit' statement in the procedure. It also does not work for me since the stored procedure keeps on executing the statements that are followed even if any error occurs (i.e. primary key violation etc.). How do I make sure that the statements in the stored procedure are rolled back or procedure exits when any error occurs in it. Thank you for helping me.

      E Offline
      E Offline
      Ennis Ray Lynch Jr
      wrote on last edited by
      #2

      set @errornum = @@error after every sql statement then check for the error number. @@error is reset after every succesful statement so if(@@error = 15) will set @@error = 0. http://www.sommarskog.se/error-handling-I.html A man said to the universe: "Sir I exist!" "However," replied the Universe, "The fact has not created in me A sense of obligation." -- Stephen Crane

      G 1 Reply Last reply
      0
      • E Ennis Ray Lynch Jr

        set @errornum = @@error after every sql statement then check for the error number. @@error is reset after every succesful statement so if(@@error = 15) will set @@error = 0. http://www.sommarskog.se/error-handling-I.html A man said to the universe: "Sir I exist!" "However," replied the Universe, "The fact has not created in me A sense of obligation." -- Stephen Crane

        G Offline
        G Offline
        Gulfraz Khan
        wrote on last edited by
        #3

        Thank you Ennis. It really works for me. and thank you for the reference URL too.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups