日期:2014-05-17 浏览次数:20375 次
--> 测试数据: @T declare @T table (col varchar(10)) insert into @T select 12345678 union all select 18760216 --预设信息1 declare @s1 varchar(20) set @s1='转成失败' --预设信息2 declare @s2 varchar(20) set @s2='转成成功' --查询 select case when isdate(col)=1 then convert(varchar(10),cast(col as datetime),120) else col end as col, case when isdate(col)=1 then @s2 else @s1 end as MessageInfo from @T /* col MessageInfo ---------- -------------------- 12345678 转成失败 1876-02-16 转成成功 */
------解决方案--------------------