creat table aa
(
maturityTime datetime, --过期时间
isMaturity int defau 0 --是否过期 0为未过期 1 为过期
)
怎样把到期后 isMaturity 字段全改成1
SOS
sql批量修改数据
答案:6 悬赏:0
解决时间 2021-10-15 15:27
- 提问者网友:爱唱彩虹
- 2021-10-14 19:23
最佳答案
- 二级知识专家网友:長槍戰八方
- 2021-05-20 23:40
update aa set ismaturity=1 where maturitytime<=getdate()
全部回答
- 1楼网友:不想翻身的咸鱼
- 2020-08-29 10:52
update aa set isMaturity =1;
- 2楼网友:毛毛
- 2021-03-18 08:25
使用update 更新修改数据库数据,更改的结果集是多条数据则为批量修改。
语法格式如:
update 表格 set 列 = 更改值 where 筛选条件
例:
update table set a=1 --将table 中所以a列的值改为 1
update table set a=1 where b=2 --将table 中列b=2的记录中a列的值改为 1
- 3楼网友:渊鱼
- 2021-06-21 15:16
基本语法:update table_name set Stockname = "xxx" [where Stockid = 3]
表名 条件
- 4楼网友:笑迎怀羞
- 2020-12-15 03:18
update aa set isMaturity =1
where maturityTime<=getdate()
同意三楼的,
就这样啊
- 5楼网友:狂恋
- 2020-05-03 19:24
绝对是你要的效果
以下代码直接可执行
此代码为临时代码
执行完毕后不会有任何数据残存
请您放心使用
代码:
declare @aa table
(
maturityTime datetime, --过期时间
isMaturity int default(0) --是否过期 0为未过期 1 为过期
)
insert @aa (maturityTime)
select dateadd(mm,-4,getdate()) union
select '2009-12-12' union
select getdate() union
select getdate() union
select '2010-1-2' union
select dateadd(mm,-3,getdate()) union
select '2009-12-1' union
select getdate() union
select dateadd(mm,-2,getdate()) union
select '2009-11-5' union
select dateadd(mm,-1,getdate())
select * from @aa
update @aa set isMaturity=1 where datediff(dd,maturityTime,getdate())>0
select * from @aa
代码到此结束
我要举报
如以上问答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯