I have a table that stores a StartDate and the name of the day of week that start date falls on. I don't know why, it is bad design but I didn't create it and can't change it. So of course, now we have some dates that don't match the day of week. To make it worse, the day of week is correct and the start date is incorrect. So what I need to do is adjust the dates so that each row's StartDate falls on that row's DayOfWeek. We can assume StartDate is always the minimum value so the target date will be the first [DayOfWeek] after the currently set StartDate.
So for example I have rows that look like this (8/23/10 was a Mon, 8/29/10 was a Sun):
StartDate DayOfWeek
-----------------------
2010-08-23 Monday
2010-08-23 Tuesday
2010-08-29 Thursday
In row 2 you can see the date is supposed to be a Tuesday but it's actually a Monday. I need to end up with this:
StartDate DayOfWeek
-----------------------
2010-08-23 Monday
2010-08-24 Tuesday
2010-09-02 Thursday
I always struggle when working with dates, but SQL is also not my strongest skill either. Thanks.