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
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 AS projectId, 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] = INNER JOIN
dbo.task AS task ON [task-assignment].[task-id] = FULL OUTER JOIN
dbo.dayentry AS dayentry ON = dayentry.[project-id] AND = dayentry.[task-id]
WHERE (project.[bill-by] = 'Tasks') AND ([task-assignment].billable = 1)
GROUP BY,, [task-assignment].[hourly-rate], [task-assignment].budget
Post #1530082
Posted Sunday, January 12, 2014 9:31 AM



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.

--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