Ini adalah contoh sederhana membuat cursor pada sql server.
USE AdventureWorks
GO
DECLARE @ProductID INT
DECLARE @getProductID CURSOR
SET @getProductID = CURSOR FOR SELECT ProductID FROM Production.Product
OPEN @getProductID
FETCH NEXT FROM @getProductID INTO @ProductIDWHILE
@@FETCH_STATUS = 0
BEGIN
PRINT @ProductID
FETCH NEXT FROM @getProductID INTO @ProductIDEND
CLOSE @getProductID
DEALLOCATE @getProductIDGO
Referensi :https://blog.sqlauthority.com
0 komentar
Post a Comment