中易网

sql批量修改数据

答案:6  悬赏:0  
解决时间 2021-10-15 15:27
creat table aa
(
maturityTime datetime, --过期时间
isMaturity int defau 0 --是否过期 0为未过期 1 为过期
)
怎样把到期后 isMaturity 字段全改成1

SOS
最佳答案
update aa set ismaturity=1 where maturitytime<=getdate()
全部回答
update aa set isMaturity =1;
使用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
基本语法:update table_name set Stockname = "xxx" [where Stockid = 3] 表名 条件
update aa set isMaturity =1 where maturityTime<=getdate() 同意三楼的, 就这样啊
绝对是你要的效果 以下代码直接可执行 此代码为临时代码 执行完毕后不会有任何数据残存 请您放心使用 代码: 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 代码到此结束
我要举报
如以上问答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
徐州到泰安怎么去合适? 正月初十在徐州坐车
北京到上海的铁路长a米,一列火车以101千米/
轩辕剑3天之痕怎么从大兴去洛阳!走那个方向
怎么识别正统藏獒的的幼崽
南昌星起点婚庆公司
苏州COCO奶茶店加盟费多少?
女人冬天手脚冰凉是什么原因?
现在杭州买火车票到南宁的要不要身份证
章子怡,汪峰怎么会在一起呢?
飞利浦原汁机怎么样
2009年铁岭农村信用社个人贷款
IOS6.1.2已经发布了,怎么升级到6.1.2
渐冻人症能活多久
北海室内设计公司或者设计室有没有好的推荐啊
孕妇在多少周做唐氏筛查检查啊?怀孕期间要做
推荐资讯
mp4格式电影用什么播放器最好?
哪位妈妈买过美特斯邦威的MooMoo童装啊?质量
跪求大连开发区所有初中学校名称与地址
福州工商年检地址
哪位清楚武清区杨村镇房价
狗狗身上出现黑点是怎么回事
22岁有黑眼圈眼袋用什么眼霜好
同房后几天受精卵着床。需要20天吗?...
广州洁霸吸尘器好吗?
三岁小孩牙疼咋办
怎样去除口中异味
比力奇50升电热水器的使用方法谁会?
手机登qq时,显示手机磁盘不足,清理后重新登
刺客的套装怎么选啊?