Sql 游标

使用SQL游标更新日期
Sql 游标,是一个很好用的东东,下面给出它的一个示例:
None.gifdeclare my_cursor1 cursor for
None.gif
select nContentId,dtEditTime from content where datepart(month,dtEditTime)='9' and datepart(day,dtEditTime)='26'
None.gif
open my_cursor1
None.gif
declare @date sysname
None.gif
declare @nID sysname
None.gif
declare @tempDate datetime
None.gif
fetch next from my_cursor1 into @nID,@date
None.gif
while(@@fetch_status = 0)
None.gif
begin
None.gif    
set @tempDate =  dateadd(day,87,@date)
None.gif    
--print @tempDate
None.gif
    update Content set dtEditTime=@tempDate where nContentId = @nID
None.gif    
fetch next from my_cursor1 into @nID,@date
None.gif
end
None.gif
close my_cursor1
None.gif
deallocate my_cursor1
用于把9月26日的日期改为:12月22日。
游标好比Sql中的指针。

转载于:https://www.cnblogs.com/stormppp/archive/2006/12/22/600647.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值