教你怎么使用sql游标--1.将每个老师的工资更新为原来的工资+奖金--定义两个变量,用来存储ttid与rewarddeclare @tid intdeclare @reward money--1。建立一个基于奖金表的游标declare cur_reward cursor fast_forward for select ttid,reward from TblTeacherSalary--2.打开游标open cur_reward--通过游标读取数据fetch next from cur_reward into @tid,@rewardwhile @@fetch_status=0begin--更新工资update TblTeacher set ttsalary=ttsalary+@reward where ttid=@tidfetch next from cur_reward into @tid,@rewardend--3.关闭游标close cur_reward--4.释放资源deallocate cur_reward说明:在一般情况下,不要使用游标。性能极点低下。 假如在处理大量数据。普通的sql 执行非常慢时,这个时候可以试试游标。也许会给你带来意想不到效果我的异常网推荐解决方案:软件开发者薪资,http://www.myexception.cn/other/1391128.html