관리 메뉴

아이짱구

WAITFOR DELAY 본문

database/mssql

WAITFOR DELAY

아이짱구 2009. 3. 24. 11:41

* 2초 대기후 실행
WAITFOR DELAY '00:00:02'


** 예: 테이블의 락 상태를 확인하여 처리하는 예제
         sp_lock 내장프로시저 소스를 보면 됨.

WHILE EXISTS(
   select  0
   from master.dbo.syslockinfo,
           master.dbo.spt_values v,
           master.dbo.spt_values x,
           master.dbo.spt_values u
   where master.dbo.syslockinfo.rsc_type = v.number
       and v.type = 'LR'
       and master.dbo.syslockinfo.req_status = x.number
       and x.type = 'LS'
       and master.dbo.syslockinfo.req_mode + 1 = u.number
       and u.type = 'L'
       and substring (v.name, 1, 4) = 'TAB'
       and rsc_objid = (SELECT Object_id('i_opening'))
)
BEGIN
   WAITFOR DELAY '00:00:02'
END

Comments