use testLeave
GO
DECLARE authors_cursor SCROLL CURSOR FOR
SELECT EmployID, CONVERT(datetime,SUBSTRING(MV021,3,6),112) FROM CMSMV
OPEN authors_cursor
DECLARE @employid varchar(10)
DECLARE @dayonjob datetime
-- Fetch the last row in the cursor.
FETCH FIRST FROM authors_cursor
into @employid, @dayonjob
UPDATE CMSMV SET DateOnJob = @dayonjob where EmployID=@employid
WHILE @@FETCH_STATUS = 0
BEGIN
FETCH NEXT FROM authors_cursor
into @employid, @dayonjob
UPDATE CMSMV SET DateOnJob = @dayonjob where EmployID=@employid
END
CLOSE authors_cursor
DEALLOCATE authors_cursor
GO