首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

请教关于在SQLSERVER中怎么取得游标中具体的一列值

2012-01-12 
请问关于在SQLSERVER中如何取得游标中具体的一列值定义游标如下DECLARECustomCursorCursorFor(Select*From

请问关于在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

热点排行