update 学生信息 set 生日=substring(身份证号,7,4)+'-'+substring(身份证号,11,2)+'-'+substring(身份证号,13,2)
where LEN(身份证号)=18
update 学生信息 set 性别='男'
where LEN(身份证号)=18 and substring(身份证号,17,1)%2=1
update 学生信息 set 性别='女'
where LEN(身份证号)=18 and substring(身份证号,17,1)%2=0
本文介绍了一种使用SQL更新语句来自动填充学生信息表中生日和性别字段的方法。通过解析学生的18位身份证号码,可以精确地提取出生年月日,并根据身份证号的最后一位数字确定性别。
464

被折叠的 条评论
为什么被折叠?



