• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 324
  • Last Modified:

update statement

Hi

can anyone give me an example of a query to update values in a table to be the same as the values in a view where the table id= view id?

Cheers
0
ac_davis2002
Asked:
ac_davis2002
  • 2
3 Solutions
 
AnujSQL Server DBACommented:
UPDATE Table
SET T.Column = V.Column
FROM Table T
INNER JOIN View V
ON V.ID = T.ID
0
 
ac_davis2002Author Commented:
sorry forgot to add the view is on a different database?
0
 
AnujSQL Server DBACommented:
So put the DatabaseName.SchemaName.ViewName in join
eg: Inner Join Sales.dbo.Products
0
 
Deepak ChauhanSQL Server DBACommented:
This is tested and working fine

Update table1 set t.column=v.column
from databasename.dbo.viewname as V
where table1.id=v.id

Please ensure that You have select permission on the other database view
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now