Solved

update statement

Posted on 2012-04-10
4
289 Views
Last Modified: 2012-04-10
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
Comment
Question by:ac_davis2002
  • 2
4 Comments
 
LVL 15

Assisted Solution

by:Anuj
Anuj earned 334 total points
ID: 37827153
UPDATE Table
SET T.Column = V.Column
FROM Table T
INNER JOIN View V
ON V.ID = T.ID
0
 

Author Comment

by:ac_davis2002
ID: 37827214
sorry forgot to add the view is on a different database?
0
 
LVL 15

Accepted Solution

by:
Anuj earned 334 total points
ID: 37827220
So put the DatabaseName.SchemaName.ViewName in join
eg: Inner Join Sales.dbo.Products
0
 
LVL 15

Assisted Solution

by:deepakChauhan
deepakChauhan earned 166 total points
ID: 37827384
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

919 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now