Basit Cursor Örneği Bu, SQL Server Cursor’un en basit örneğidir. Bunu çoğu zaman T-SQL’imizde herhangi bir Cursor kullanımı için kullanıyoruz. DECLARE @AccountID INT DECLARE @getAccountID CURSOR SET @getAccountID = CURSOR FOR SELECT Account_ID FROM Accounts OPEN @getAccountID FETCH NEXT FROM @getAccountID INTO @AccountID WHILE @@FETCH_STATUS = 0 BEGIN PRINT @AccountID FETCH NEXT FROM @getAccountID INTO @AccountID END CLOSE @getAccountID DEALLOCATE @getAccountID
Bu, SQL Server Cursor’un en basit örneğidir. Bunu çoğu zaman T-SQL’imizde herhangi bir Cursor kullanımı için kullanıyoruz.
DECLARE @AccountID INT
DECLARE @getAccountID CURSOR
SET @getAccountID = CURSOR FOR
SELECT Account_ID
FROM Accounts
OPEN @getAccountID
FETCH NEXT
FROM @getAccountID INTO @AccountID
WHILE @@FETCH_STATUS = 0
BEGIN
PRINT @AccountID
FETCH NEXT
FROM @getAccountID INTO @AccountID
END
CLOSE @getAccountID
DEALLOCATE @getAccountID
Size ve Veritabanlarınıza Yardımcı Olmak İçin Bekliyoruz!