English 中文(简体)
ql Update with another table
原标题:sql update with another table
  • 时间:2009-11-23 18:41:59
  •  标签:
  • sql-server

我如何写上Microsoftkou服务器的指挥,以更新每行,并附上第二张表格的相应价值?

UPDATE Person SET 
FirstName=Temp.FirstName
FROM Temp
WHERE Temp.PersonID=Person.PersonID

Here I want to replace every FirstName with Temp.Firstname where the personid in Person is equal to Temp.PersonID

最佳回答
UPDATE P
SET FirstName=T.FirstName
FROM Person P
JOIN Temp T
ON T.PersonID=P.PersonID
问题回答

你们是否尝试过听从?

UPDATE Person SET 
FirstName = (SELECT Temp.FirstName FROM Temp WHERE Temp.PersonID=Person.PersonID)




相关问题
Export tables from SQL Server to be imported to Oracle 10g

I m trying to export some tables from SQL Server 2005 and then create those tables and populate them in Oracle. I have about 10 tables, varying from 4 columns up to 25. I m not using any constraints/...

SQL server: Can NT accounts be mapped to SQL server accounts

In our database we have an SQL server account that has the correct roles to access some of the databases. We are now switching to windows authentication and I was wondering if we can create a NT user ...

SQL Server 2000, ADO 2.8, VB6

How to determine if a Transaction is active i.e. before issuing Begin Transaction I want to ensure that no previous transaction are open.. the platform is VB6, MS-SQL Server 2000 and ADO 2.8

热门标签