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. updating table of one database with data from another database?

updating table of one database with data from another database?

Scheduled Pinned Locked Moved Database
databasequestionannouncement
4 Posts 4 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.
  • P Offline
    P Offline
    PandemoniumPasha
    wrote on last edited by
    #1

    hi, i have two databases which are used for different projects. but i need to update a column of one database with the data from another database. is there a way to do that using SPs? or any other way? thanks. regards.

    M Z P 3 Replies Last reply
    0
    • P PandemoniumPasha

      hi, i have two databases which are used for different projects. but i need to update a column of one database with the data from another database. is there a way to do that using SPs? or any other way? thanks. regards.

      M Offline
      M Offline
      mghiassi
      wrote on last edited by
      #2

      You can do this job by these statement. 1)Declare a Variable like v 2)Select the record you want use by SELECT Statement and assign it to the v by = operator 3)Update the record you want by UPDATE Statement and set it to the v. I hope this solution is useful

      1 Reply Last reply
      0
      • P PandemoniumPasha

        hi, i have two databases which are used for different projects. but i need to update a column of one database with the data from another database. is there a way to do that using SPs? or any other way? thanks. regards.

        Z Offline
        Z Offline
        Ziyad Mohammad
        wrote on last edited by
        #3

        Here we go!! Use joins (normal, left or right) between tables across the databases. You can call different databases in TSQL with dot operators (..). Eg:- Select n.name from northwind..authors n, pubs..aurhors p where p.authorid = n.authorid

        Thanks, Ziyad Mohammad[http://www.dotnetsoldier.blogspot.com/]

        1 Reply Last reply
        0
        • P PandemoniumPasha

          hi, i have two databases which are used for different projects. but i need to update a column of one database with the data from another database. is there a way to do that using SPs? or any other way? thanks. regards.

          P Offline
          P Offline
          Pete OHanlon
          wrote on last edited by
          #4

          You need to prefix the schema.tablename with the name of the database. For instance:

          Update database1.myschema.table1 set value = 10 where id = 20
          

          Deja View - the feeling that you've seen this post before.

          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