SQL 2008 R2 - Update a table using VIEW?

  • 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

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


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply