Possible to do an Update/Select Like an Insert/Select?

  • I can do an Insert/Select all together in a Stored Proc such as:

    INSERT INTO tblReportTemp (EmpName, Emp_Class, Month_ForCount, Month_AgainstCount, Month_CountCalls, Month_ApprovedLeave, Month_Percent)

    SELECT EmpName, Emp_Class, Month_ForCountSum, Month_AgainstCountSum, Month_CountCallsSum, Month_ApprovedLeaveSum, Month_Percent

    FROM MyView

    Is there a way to do a similiar thing with an update such that I update based off of a query?

  • Just like this:

    UPDATE tablename

    SET columnname = (SELECT columnname FROM tablename WHERE ?????)

    WHERE ?????

  • Wow, that takes forever to complete....

  • Look for Update From.

    Update mytable

    set col1 = somevalue

    From SomeTable

    Join mytable on somecol = othercol

     

    please present table, data, and your expected results and someone should be able to help

  • Hey thanks that was more in line with what I was looking for. I appreicate the help.

Viewing 5 posts - 1 through 4 (of 4 total)

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