sqlserver游标的简单使用

 时间:2024-10-31 00:59:48

1、第一步:在定义游标之前,需要先定义变量,本示例中只涉及三个需要用到的变量price,sums和name在查询分析器中输入一行代码declare @price float,@sums int,@name nvarchar(10)

sqlserver游标的简单使用

3、第三步:打开游标并取一行数据,openc_updateTotalfetch next fromc_updateTotal into @price,@sums,@name

sqlserver游标的简单使用

5、第五步:在循环中间添加更新语句来批量对每一行进行修改update product set total =@price*@sums where name=@name

sqlserver游标的简单使用

7、第七步:完成,开始执行修改,以下为完整代码declare @price float,@sums int,@name nvar艘早祓胂char(10)declare c_updateTotal cursor forselect price , sums,name from productopen c_updateTotalfetch next from c_updateTotal into @price,@sums,@namewhile @@FETCH_STATUS=0begin--这里处理一些数据update product set total =@price*@sums where name=@namefetch next from c_updateTotal into @price,@sums,@nameendclose c_updateTotaldeallocate c_updateTotal

  • word中给矩形标注添加紫色复合型轮廓样式
  • word样式怎么设置
  • word2019设置形状的轮廓
  • WORD文档偏右式分栏怎么设置
  • Word 如何修改样式
  • 热门搜索
    桂林到阳朔怎么走 西米露怎么做 肩周炎怎么治疗 怎么证明输卵管是通的 玫瑰花怎么折 血压压差小是怎么回事 跟腱炎怎么治疗 最小公倍数怎么求 社保怎么查 安卓手机怎么投屏到电视