1

I want to update my table from another table in another database.I have two table that has two same columns.There are ID and iexp column.What i want is update every row from k_monster table to my database's k_monster table but there are other columns such as iHP iMP so i want to just update iExp column.what do you suggest?

David Faber
  • 12,277
  • 2
  • 29
  • 40
  • Are you using SQL Server, MySQL, Oracle ... ? – David Faber Jan 03 '15 at 23:04
  • possible duplicate of [UPDATE record in one database with values from another in SQL Server 2008?](http://stackoverflow.com/questions/5735123/update-record-in-one-database-with-values-from-another-in-sql-server-2008) – Tahbaza Jan 03 '15 at 23:34

2 Answers2

1

Assuming Target_Database is the database where the table is that you want to update and Source_Database is the database where the table is you are using to update from.

Your query should look something like this.....

USE [Target_Database]
GO

UPDATE t
 SET t.iexp  = S.iexp 
FROM K_monster t 
INNER JOIN [Source_Database].[Schema].[K_monster] S 
ON t.ID = S.ID
GO
M.Ali
  • 67,945
  • 13
  • 101
  • 127
  • thank you bro!solved USE [KN_Online] GO UPDATE t SET t.iExp = S.iExp FROM K_Monster t INNER JOIN [newmyko].[dbo].[K_Monster] S ON t.ssid = S.ssid GO –  Jan 04 '15 at 09:35
0

Please check this link similar to this type of question:

Additionally I would suggest you to search before you ask any questions.

UPDATE record in one database with values from another in SQL Server 2008?

This link has similar answer to your question.

More links:

Update database table from one SQL Server database table to another?

https://dba.stackexchange.com/questions/30228/how-to-update-one-database-from-another

https://dba.stackexchange.com/questions/58371/sql-update-column-with-data-from-another-table

With Regards

Community
  • 1
  • 1
TMNT
  • 156
  • 1
  • 10
  • 2
    You should write a quick review when you are posting links in case that some of useful content from those links could be deleted in future. – Hoh Jan 03 '15 at 23:54
  • @TMNT - As the other user said, please post some useful content from the links. Your answer will become useless once the links are deleted. – Erran Morad Jan 04 '15 at 00:22