从另一个表SQL更新列值 [英] Updating columns values from another table SQL
问题描述
我想更新我的表从另一个数据库中的表。我有两个表有两个相同的列。有ID和iexp列。我想要的是更新每一行从k_monster表到我的数据库的k_monster表,但有是其他列,如iHP iMP所以我只想更新iExp列。你建议什么?
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?
推荐答案
$ c> Target_Database 是要更新表的数据库, Source_Database
是您正在使用的表更新的数据库从。
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
这篇关于从另一个表SQL更新列值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!