Suppose that I have this Time value: 09:00:00
And I have a table with a column Time, and I have three records in it.
I want to update those 3 records with that time but with the Time value incremented in one second each time (for every record).
Something like this:
ColumnA ColumnB
1 09:00:00
2 09:00:01
3 09:00:02
How can I do that?
My Solution:
After some time working on my own solution, this is what I came up with
update tor1
set ColumnB = dateadd(s,tor2.inc, ColumnB)
from table1 tor1
inner join (select ColumnA, ROW_NUMBER() OVER (Order by ColumnA) as inc from table1) tor2 on tor1.ColumnA=tor2.ColumnA