>I've imported a table and some of the rows have blank values
>
>I want to update the empty values of CaseID with the preceding value so in this example all the NULL CaseID will be 122303.
>I don't mind about the other columns its just the CaseID I want
>
>
>INC CaseID Status
>N 122303 Open: Investigation
>NULL NULL NULL
>NULL NULL NULL
>NULL NULL NULL
>N 122331 Open: Investigation
>
>
>Any suggestions on some SQL to do that ?
>
>Thanks
>
>Nick
SQL does not have a defined order,
however, with a virgin table a simple update flowing rows in in which were inserted
DECLARE @test TABLE (INC char(1), CaseID int, Status varchar(50));
INSERT INTO @test (INC, CaseID, Status)
VALUES
('N', 122003, 'Open: Investigation'),
('N', 122303, 'Open: Investigation'),
(NULL, NULL, NULL),
(NULL, NULL, NULL),
(NULL, NULL, NULL),
('N', 122330, 'Open: Investigation'),
('N', 122331, 'Open: Investigation'),
(NULL, NULL, NULL),
(NULL, NULL, NULL),
('N', 122431, 'Open: Investigation')
DECLARE @CaseID INT
UPDATE @test SET @CaseID = CaseID = ISNULL(CaseID,@CaseID)
SELECT * FROM @test