熱門文章

2010年7月16日 星期五

MSSQL 簡單 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

沒有留言:

張貼留言