April 20, 2002 at 2:04 pm
In a table containing a sparse column (mainly) NULLS, is there any way with TSQL under SQL2000 to propagate a clomun value down the column replacing the NULLS until encountering another "NOT NULL" value?
April 20, 2002 at 7:32 pm
Would the non null rows have a relationship to the null rows other than physical order? Conceptually I think a cursor is easiest to envision, sort the data however makes sense, then keep track of the last non null value and update as you go. Set based is better when you can manage, not sure how to approach it in this case. Perhaps other readers will!
Andy
April 21, 2002 at 4:16 pm
Since SQL Server doesn't track physical order, you need someway to order the rows. As Ansy said, you can use a cursor, but you still need ordering.
Steve Jones
April 22, 2002 at 8:24 am
Thanks, folks, for the suggestions. I finally resorted to the cursor method. Takes about 10 minutes to do 300k rows.
I'm sure the problem could be solved in
a better way but this works OK for now.
Thanks, Bill Washburn
April 22, 2002 at 10:44 am
If you could post your cursor we can look at offer suggestions since this will give us an idea of what exactly you are doing.
"Don't roll your eyes at me. I will tape them in place." (Teacher on Boston Public)
April 22, 2002 at 12:13 pm
10 mins aint bad! Will you end up reprocessing all 300k rows every day?
Andy
April 22, 2002 at 12:27 pm
Thanks folks,
Turns out to be 10min to load 350k into first
table, select out and load 5 tables and then
do the cursor fixup on the FK table.
It will run each night. I will post also but
am busy today with crazy time here at work.
Bill Washburn
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply