Monday, 28 September 2009

Using T-SQL in Sql Server

http://justgeeks.blogspot.com/2008/08/using-t-sql-cursor-in-sql-server.html

DECLARE @price money
DECLARE @get_price CURSOR

SET @get_price = CURSOR FOR
SELECT price FROM titles
OPEN @get_price
FETCH NEXT FROM @get_price INTO @price
WHILE (@@FETCH_STATUS = 0)

BEGIN IF @Price < 20 SELECT ‘Under 20′ ELSE SELECT @Price
FETCH NEXT FROM @get_price INTO @priceEND

CLOSE @get_price
DEALLOCATE @get_price

--------------------------------------------------------------------------------------

No comments:

Post a Comment