修改时间

博客展示了一段 SQL 代码,通过声明游标 cursor_time 和 cursor_user,从 att_original 表中筛选特定日期的数据,将时间部分与固定日期组合后更新到表中,最后关闭并释放游标,还给出了查询表数据的语句。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

declare @time varchar(8),@datetime datetime

declare cursor_time cursor for select right(datetime,8) from att_original where left(datetime,10) = '06 11 2003'
open cursor_time
fetch next from cursor_time into @time

declare cursor_user cursor for select * from att_original  where left(datetime,10) = '06 11 2003'
open cursor_user

fetch next from cursor_user

while @@fetch_status = 0
begin
  set @datetime = '2005-06-11 '+ '' + @time
  update att_original set datetime = @datetime where current of cursor_user

  fetch next from cursor_user
  fetch next from cursor_time into @time
end

 

close cursor_user
deallocate cursor_user

close cursor_time
deallocate cursor_time

select * from att_original

转载于:https://www.cnblogs.com/eagletian/archive/2005/06/23/179854.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值