CREATE proc Upadte_stateas update Table_1 set [state]=2 where id in (select id from Table_1 where state=1 and GETDATE()>=tiemdate) go