跳到主要內容

發表文章

目前顯示的是 12月, 2010的文章

T-SQL Cursor Loop Sample

GO DECLARE @value1 varchar(50) DECLARE @value2 varchar(50) DECLARE my_cursor CURSOR FOR SELECT Value1,value2 FROM TableName OPEN my_cursor FETCH NEXT FROM my_cursor INTO @value1,@value2 WHILE @@FETCH_STATUS = 0 BEGIN print @value1 + ':' + @value2 /*Main Process Start*/ FETCH NEXT FROM my_cursor INTO @value1,@value2 end CLOSE my_cursor DEALLOCATE my_cursor