Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

update statement

Posted on 2012-04-10
4
294 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:Deepak Chauhan
Deepak Chauhan 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

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

Suggested Solutions

A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.

792 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