declare @ActionDesc nvarchar(max) -- 一个策略字段:(目的是为了确认唯一的一行数据内容),联想到Group by的用法,
--group by前面的一个字段是为了统计,后面是要分组的字段,然后得到要统计的字段(面向对象思想)
declare @ID uniqueidentifier
declare cursor1 cursor for --定义游标
select ID,ActionDesc from T_OperatorLog t --使用游标的对象(跟据需要填入select文)
open cursor1 --打开游标
fetch next from cursor1 into @ID,@ActionDesc --将游标向下移行,获取的数据放入之前定义的变量@id,@name中
while @@fetch_status=0 --判断是否成功获取数据
begin
if(@ActionDesc='描述3')
update T_OperatorLog set ActionDesc='修改的描述' where ID=@ID --进行相应处理(跟据需要填入SQL文)
fetch next from cursor1 into @ID,@ActionDesc --将游标向下移行
end
select * into #temp1 from T_OperatorLog where ActionDesc='修改的描述' --把上面游标修改好的结果集放入到临时表中
close cursor1 --关闭游标
deallocate cursor1 --撤销游标
select * from #temp1 --从临时表中取到刚才得到的结果集
drop table #temp1 --删除临时表