Skip to content
Advertisement

Need to update column from derived column of select statement

I’ve this below select statement. Over there I’ve 2 derived columns EmpContbtnWithoutTax and EmpContbtnWithTax I wanted to have that data permanently in that same table EmpPFContributionTest

enter image description here

Need help to have that update query for EmpPFContributionTest table which update the respective rows of EmpContbtnWithoutTax and EmpContbtnWithTax columns permanently. Update script which I was trying for 1 column first mentioned below

Advertisement

Answer

It look like you’re trying to update two existing columns in the same table?

It’s not a good pattern to use where the data is computed from existing data – when the data changes your computed values are instantly invalidated.

Having said that, to do what you are asking you can simply use an updatable CTE, something like:

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement