这里是普通文章模块栏目内容页
游标

游标的最好方式是不用游标。

游标替代方案:

--Declare variables
DECLARE @item_category_id INT
Declare @X BIGINT
Set @X = 0
--Declare a memory table
DECLARE @item_table TABLE (item_category_id INT)

INSERT INTO @item_table(item_category_id)
SELECT  object_id
From master.sys.objects c1(NOLOCK)

--WHILE @loop_counter > 0 AND @item_category_counter <= @loop_counter
WHILE (SELECT COUNT(1) FROM @item_table) > 0
BEGIN
    SELECT TOP 1 @item_category_id = item_category_id
    FROM @item_table 

    --处理
    Set @X = @X + @item_category_id

   delete from @item_table where item_category_id = @item_category_id
END
PRINT @X
栏目索引
相关内容