Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

SQL 2008 R2 - Update a table using VIEW? Expand / Collapse
Author
Message
Posted Sunday, January 12, 2014 12:59 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Monday, January 13, 2014 9:40 PM
Points: 7, Visits: 66
I have the below VIEW that I now want to use the selected columns to UPDATE another table with the same 'ProjectId'..
Can anyone assist me please ?



SELECT project.id AS projectId, task.id AS taskId, [task-assignment].[hourly-rate] * [task-assignment].budget AS BudgetValue,
[task-assignment].[hourly-rate] * SUM(dayentry.hours) AS ActualValue, SUM(dayentry.hours) AS ActualHours, [task-assignment].budget AS BudgetHours
FROM dbo.[task-assignment] AS [task-assignment] INNER JOIN
dbo.project AS project ON [task-assignment].[project-id] = project.id INNER JOIN
dbo.task AS task ON [task-assignment].[task-id] = task.id FULL OUTER JOIN
dbo.dayentry AS dayentry ON project.id = dayentry.[project-id] AND task.id = dayentry.[task-id]
WHERE (project.[bill-by] = 'Tasks') AND ([task-assignment].billable = 1)
GROUP BY project.id, task.id, [task-assignment].[hourly-rate], [task-assignment].budget
Post #1530082
Posted Sunday, January 12, 2014 9:31 AM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: General Forum Members
Last Login: Today @ 7:24 AM
Points: 35,945, Visits: 30,230
This is a duplicate post. No replies on this thread, please. It just splits the answers up. Please refer to the following URL to get to the other post. Thanks.
http://www.sqlservercentral.com/Forums/Topic1530081-391-1.aspx


--Jeff Moden
"RBAR is pronounced "ree-bar" and is a "Modenism" for "Row-By-Agonizing-Row".

First step towards the paradigm shift of writing Set Based code:
Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column."

"Change is inevitable. Change for the better is not." -- 04 August 2013
(play on words) "Just because you CAN do something in T-SQL, doesn't mean you SHOULDN'T." --22 Aug 2013

Helpful Links:
How to post code problems
How to post performance problems
Post #1530113
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse