27,579
社区成员
发帖
与我相关
我的任务
分享
select isdate('19'+'800503')
--1
select isdate('19'+'801303')
--0
--用isdate()检查出生日期不合格的。
select * from ryjbqk
where isdate('19'+ltrim(substring(f_sfzh,7,6)))<>1 and len(f_sfzh)=15
declare @s varchar(20)
set @s='19990909'
select CONVERT(datetime,@s,112)
-----------------------
1999-09-09 00:00:00.000
update ryjbqk
set f_csrq= convert(datetime,'19'+substring(f_sfzh,7,6), 112)
where len(f_sfzh)=15
--或者
update ryjbqk set f_csrq= '19'+ltrim(substring(f_sfzh,7,6))
where len(f_sfzh)=15
update ryjbqk set f_csrq=cast( ('19'+substring(f_sfzh,7,6)) as datetime) where len(f_sfzh)=15