Solved

update statement

Posted on 2012-04-10
4
298 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
[X]
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
  • 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

Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

Question has a verified solution.

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

Suggested Solutions

For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

737 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