long running process sql implemntation