Hi
I receive several datafiles from another system that are more or less in a Excel pivot table like format.
That is the first row representing the current data is fully filled, while subsequent rows, representing historic data are left partly empty.
Current rows and historic rows have different identifiers, e.g. rectype=0 or 1
Filling out the missing data on the historic record should be simple, if only all current rows would be filled.
Some current rows aren't filled, so the stuff like the following doesn't work:
update t1
set t1.colA =
(
select top 1 t2.colA
from mytable AS t2
where t2.rowid <= t1.rowid
and t2.cola <> 0
order by t2.rowid desc
)
from mytable AS t1
Somehow I need to check for the rectype, so I don't fill out rows with data from a previous entity
Any suggestions before I revert to using a cursor?
And while we are at it: I am in for an easy way to do this for all (about 60) colums in one move?
Before you ask:
After filling everything out we process the file to arrive at a few handy fromto tables, so we can use the correct data about the entity's status at a particular point in time elsewhere
I am using MS SQL Server 2005, and solutions are allowd to use any specific trickery that MSSQL allows.
Many thanks for any constructive thoughts
Cheers
Drio