9 Eylül 2008 Salı

MSSQL de Select ile aldigimiz datalar arasinda gezmek


DECLARE @Degisken as money
DECLARE @Count AS INT
SET @Count = 0
DECLARE test_cursor CURSOR
FOR
Select TOP 4 alanadi from tabloadi ORDER BY ID DESC
OPEN test_cursor

FETCH NEXT FROM test_cursor INTO @Degisken
WHILE (@@FETCH_STATUS <> -1)--bitti mi ?
BEGIN
IF (@Degisken is NULL OR @Degisken = 0)
begin
SET @Count = @Count +1--sayiyi artir
END
FETCH NEXT FROM test_cursor INTO @Degisken
END
CLOSE test_cursor
DEALLOCATE test_cursor
SELECT @Count --sonucu goruntule

Hiç yorum yok: