I have a really inefficient sql script that takes the following table, and populates val2 using a cursor. I want to be able to update all of the val2 values with a single update, but val2 is calculated using val1 for each row.
val1: 1, val2 0
val1: 2, val2 0
val1: 3, val2 0
val1: 4, val2 0
val1: 5, val2 0
So I imagine, you'd have something like this:
UPDATE Table SET val2 = (some code based on val1 for each row)
How can I write this into a single line of sql?