日期:2014-05-19  浏览次数:20575 次

请问关于在SQLSERVER中如何取得游标中具体的一列值
定义游标如下

DECLARE   CustomCursor   Cursor   For   (Select   *   From   Customs)
OPEN         CustomCursor

FETCH   NEXT   FROM   CustomCursor;
        WHILE   @@FETCH_STATUS   =   0
        BEGIN
                --我在这里想获得游标当前数据中Customs表中的列A1,A2……A9999的值
                FETCH   NEXT   FROM   ClubGuid;
        END;

CLOSE   CustomCursor
DEALLOCATE   CustomCursor

多谢帮忙!

------解决方案--------------------
--试试
declare @a1 varchar,@a2 varchar……
DECLARE CustomCursor Cursor For (Select * From Customs)
OPEN CustomCursor

FETCH NEXT FROM CustomCursor into @a1,@a2……
WHILE @@FETCH_STATUS = 0
BEGIN
--我在这里想获得游标当前数据中Customs表中的列A1,A2……A9999的值
FETCH NEXT FROM CustomCursor into @a1,@a2……
END

CLOSE CustomCursor
DEALLOCATE CustomCursor

------解决方案--------------------
--try


DECLARE CustomCursor Cursor For (Select * From Customs)
OPEN CustomCursor

declare @A1 varchar(100), ....
FETCH NEXT FROM CustomCursor into @A1, ...
WHILE @@FETCH_STATUS = 0
BEGIN
--我在这里想获得游标当前数据中Customs表中的列A1,A2……A9999的值
FETCH NEXT FROM ClubGuid into @A1, ...
END;

CLOSE CustomCursor
DEALLOCATE CustomCursor
------解决方案--------------------
declare @column varchar(1000)
DECLARE CustomCursor Cursor For (Select * From Customs)
OPEN CustomCursor

FETCH NEXT FROM CustomCursor INTO @column ;--- 在这获得数据
WHILE @@FETCH_STATUS = 0
BEGIN
--我在这里想获得游标当前数据中Customs表中的列A1,A2……A9999的值
FETCH NEXT FROM ClubGuid INTO @column ;--- 在这获得下一个数据
END;

CLOSE CustomCursor
DEALLOCATE CustomCursor