日期:2014-05-17 浏览次数:20424 次
select CAST(substring('sfzh',7,8) AS SMALLDATETIME)
------解决方案--------------------
如果不是数据问题那么就是你substring里面取位的问题,你可以像我那样先调用substring看看是否正确再转换
WITH test (sfzh) AS (SELECT 'abcdef20121015') SELECT substring(sfzh,7,8),CAST(substring(sfzh,7,8) AS SMALLDATETIME) FROM test /* -------------- ----------------------- 20121015 2012-10-15 00:00:00 (1 行受影响) */