Pythontr

husonet | Tarih: 12.10.2016

MS SQL CURSOR - IF ELSE KULLANIMI

MS SQL DE CURSORDE IF ELSE KULLANIMI

DECLARE @DOGUMTARIH SMALLDATETIME 
DECLARE @SICILKOD VARCHAR(30)
DECLARE X_CURSOR CURSOR FOR
SELECT SICILKOD FROM PERKRT ORDER BY SICILKOD
OPEN X_CURSOR FETCH NEXT FROM X_CURSOR INTO @SICILKOD
WHILE (@@FETCH_STATUS = 0)
BEGIN
IF @DOGUMTARIH <'19730101'
UPDATE PERKRT SET BKOD1 =1 WHERE SICILKOD=@SICILKOD
ELSE
UPDATE PERKRT SET BKOD1 =2 WHERE SICILKOD=@SICILKOD
FETCH NEXT FROM X_CURSOR INTO @SICILKOD
END
CLOSE X_CURSOR
DEALLOCATE X_CURSOR