从身份证号提取生日并更新到生日字段中的SQL语句

1:根据身份证号 更新 生日字段 SQL

update 学生信息 set 生日=substring(身份证号,7,4)+'-'+substring(身份证号,11,2)+'-'+substring(身份证号,13,2)
where LEN(身份证号)=18

2:根据身份证号 更新 性别字段 SQL

update 学生信息 set 性别=''
where LEN(身份证号)=18 and substring(身份证号,17,1)%2=1
update 学生信息 set 性别=''
where LEN(身份证号)=18 and substring(身份证号,17,1)%2=0

 

posted @ 2019-07-02 14:45  大da脸  阅读(1956)  评论(0编辑  收藏  举报