老问题,刚才的时间转换问题 可以啊:declare @str varchar(20)set @str='20040910'select cast(@str as smalldatetime) 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 declare @str varchar (8)set @str='20040901'select cast(@str as smalldatetime) 这样转会出错:declare @i int set @i=20040910select cast(@i as smalldatetime) --两个都可以cast convertdeclare @str char(8)set @str='20040910'select cast(@str as smalldatetime)select convert(smalldatetime,@str,120) --为int时这样declare @i int set @i=20040910select convert(smalldatetime, cast(@i as varchar(20))) 如果是非法日期,错误:从 char 数据类型到 smalldatetime 数据类型的转换导致 smalldatetime 值越界就是你说的溢出吧 为20040931时出错的:从 char 数据类型到 smalldatetime 数据类型的转换导致 smalldatetime 值越界。 sql语句 mysql 如下,建个视图,个索引视图怎么建才行呢? 救命!我的SQL Server 2000不好用了! 大虾请进(入门问题) 把exec 的输出放在临时变量中 各位,急求这个sql语句的写法,非常谢谢 请教2个SQL语句~特急~ 高手帮帮忙! 杨家将 , 怎样把另一电脑的数据库移过来 ? 请问统计一个员工的一个月的数据要按周来统计! 求一条查询语句
set @str='20040901'
select
cast(@str as smalldatetime)
declare @i int
set @i=20040910
select cast(@i as smalldatetime)
declare @str char(8)
set @str='20040910'
select cast(@str as smalldatetime)
select convert(smalldatetime,@str,120)
declare @i int
set @i=20040910
select convert(smalldatetime, cast(@i as varchar(20)))
从 char 数据类型到 smalldatetime 数据类型的转换导致 smalldatetime 值越界
就是你说的溢出吧
从 char 数据类型到 smalldatetime 数据类型的转换导致 smalldatetime 值越界。