Updated stored procedure to update/insert staged data.