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. Using trigger to insert data into seperate database.

Using trigger to insert data into seperate database.

Scheduled Pinned Locked Moved Database
databasequestion
5 Posts 3 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.
  • F Offline
    F Offline
    flippydeflippydebop
    wrote on last edited by
    #1

    Hello c'pians, I have got two SQL databases on seperate machines (master/slave). I am able to connect to both the databases using Enterprise Manager. Both databases have identical tables. What i would like to do is write a trigger which fires when a new row is inserted into the master db and inserts the same data into the slave database. What i would like to know is, is it possible to write a trigger which can insert data into a completly seperate database?

    P A 2 Replies Last reply
    0
    • F flippydeflippydebop

      Hello c'pians, I have got two SQL databases on seperate machines (master/slave). I am able to connect to both the databases using Enterprise Manager. Both databases have identical tables. What i would like to do is write a trigger which fires when a new row is inserted into the master db and inserts the same data into the slave database. What i would like to know is, is it possible to write a trigger which can insert data into a completly seperate database?

      P Offline
      P Offline
      Private_Void
      wrote on last edited by
      #2

      It is possible and fairly straight forward. I am doing this from memory as I only have SQL Server 2005 in front of me (so forgive if directions are slightly off). Open Enterprise Manager, create a linked server on the master DB to the slave DB. Then you will be able to access the slave DB in your trigger basically as if you were acessig another (local) DB. I hope this helps.

      1 Reply Last reply
      0
      • F flippydeflippydebop

        Hello c'pians, I have got two SQL databases on seperate machines (master/slave). I am able to connect to both the databases using Enterprise Manager. Both databases have identical tables. What i would like to do is write a trigger which fires when a new row is inserted into the master db and inserts the same data into the slave database. What i would like to know is, is it possible to write a trigger which can insert data into a completly seperate database?

        A Offline
        A Offline
        Amit Kumar G
        wrote on last edited by
        #3

        Yes, use linked server. Steps would be a) Create Linked server for your slave on master server by using enterprise mgr or sp_addlinkedserver. b) Write Trigger on master table...and do somothing like as below Insert into Slave.Table values(..............) where slave is linked server name..... Simple........ Amit

        F 2 Replies Last reply
        0
        • A Amit Kumar G

          Yes, use linked server. Steps would be a) Create Linked server for your slave on master server by using enterprise mgr or sp_addlinkedserver. b) Write Trigger on master table...and do somothing like as below Insert into Slave.Table values(..............) where slave is linked server name..... Simple........ Amit

          F Offline
          F Offline
          flippydeflippydebop
          wrote on last edited by
          #4

          hey guys... cheers ever so much for this.. I will be looking into this first thing monday morning. :):):)

          1 Reply Last reply
          0
          • A Amit Kumar G

            Yes, use linked server. Steps would be a) Create Linked server for your slave on master server by using enterprise mgr or sp_addlinkedserver. b) Write Trigger on master table...and do somothing like as below Insert into Slave.Table values(..............) where slave is linked server name..... Simple........ Amit

            F Offline
            F Offline
            flippydeflippydebop
            wrote on last edited by
            #5

            i have just found this good guide on using linked servers http://www.informit.com/articles/article.asp?p=21644&rl=1[^] thanks again

            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