[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

update statement

Posted on 2012-04-10
4
Medium Priority
?
322 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 1336 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 1336 total points
ID: 37827220
So put the DatabaseName.SchemaName.ViewName in join
eg: Inner Join Sales.dbo.Products
0
 
LVL 16

Assisted Solution

by:Deepak Chauhan
Deepak Chauhan earned 664 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

Transaction-level recovery for Oracle database

Veeam Explore for Oracle delivers low RTOs and RPOs with agentless transaction log backup and transaction-level recovery of Oracle databases. You can restore the database to a precise point in time, even to a specific transaction.

Question has a verified solution.

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

When trying to connect from SSMS v17.x to a SQL Server Integration Services 2016 instance or previous version, you get the error “Connecting to the Integration Services service on the computer failed with the following error: 'The specified service …
This shares a stored procedure to retrieve permissions for a given user on the current database or across all databases on a server.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.
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.
Suggested Courses

834 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