關於我

我的相片
用心思考、保持熱情,把工作上的經驗作分享與紀錄。希望能夠跟大家一起不斷的成長~

簡單 T-SQL Cursor 範例

DECLARE InvoiceOID_cursor CURSOR FOR 
select oid from Invoice
OPEN InvoiceOID_cursor 
FETCH NEXT FROM InvoiceOID_cursor INTO @InvoiceOID
WHILE @@FETCH_STATUS = 0
BEGIN
    --    PRINT @message
    --    delete from XXX where oid = @InvoiceOID
    --    Do Something !
    FETCH NEXT FROM InvoiceOID_cursor INTO @InvoiceOID
END 
CLOSE InvoiceOID_cursor
DEALLOCATE InvoiceOID_cursor

沒有留言:

張貼留言