DECLARE @Hid varchar(50), @Hname varchar(50)declare contact_cursor cursor for --声明游标select hotel_id,h_name from hotel where hotel_id<25open contact_cursor --打开游标fetch next from contact_cursor into @Hid,@Hname --游标指针下移一行while @@fetch_status=0 --FETCH语句执行成功begin print @Hid + @Hname fetch next from contact_cursor into @Hid,@HnameendCLOSE contact_cursor --关闭游标DEALLOCATE contact_cursor --释放游标
fetch next from contact_cursor into @Hid,@Hname 这段语句就是把 hotel_id 和 h_name 字段赋值给 @Hid,@Hname
print @Hid + @Hname 就是把hotel表里的hotel_id和h_name字段打印出来
posted on 2013-03-13 11:37 阅读( ...) 评论( ...)