数据类型

gagaxiaoyuer 2008-03-03 04:42:38
对数据类型而言运算符无效。运算符为 subtract,类型为 nvarchar。 我现在用的 NVARCHAR 但是我想把两个数相减 我应该改成什么数据类型最好
...全文
102 16 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
16 条回复
切换为时间正序
请发表友善的回复…
发表回复
wzy_love_sly 2008-03-03
  • 打赏
  • 举报
回复
为啥呢,加我qq,260831750,我看看
gagaxiaoyuer 2008-03-03
  • 打赏
  • 举报
回复
大鸟 啊 大鸟 很头痛啊 我用XP 虽然提示丢失 但是能转 现在用2000 死都转不了
忆轩辕 2008-03-03
  • 打赏
  • 举报
回复
我靠,字符'a1'能转成数字才见鬼了
wzy_love_sly 2008-03-03
  • 打赏
  • 举报
回复
declare @tb table (name varchar(10))
insert into @tb select null
insert into @tb select '123'
insert into @tb select 'a1'

select * from @tb
where isnumeric(name)=0

NULL
a1


用这个查一下,看有转换错误的没
wzy_love_sly 2008-03-03
  • 打赏
  • 举报
回复
declare @tb table (name varchar(10))
insert into @tb select null
insert into @tb select '123'
insert into @tb select 'a1'


select cast(name as decimal(18,2)) from @tb


消息 8114,级别 16,状态 5,第 8 行
从数据类型 varchar 转换为 numeric 时出错。
wzy_love_sly 2008-03-03
  • 打赏
  • 举报
回复
怎么转的?
多半有不能转换的数据吧
gagaxiaoyuer 2008-03-03
  • 打赏
  • 举报
回复
ODBC 错误: [Microsoft][ODBC SQL Server Driver][SQL Server]将数据类型 nvarchar 转换为 numeric 时出错。

那天强制转都还行 !! 今天怎么就不行了
wzy_love_sly 2008-03-03
  • 打赏
  • 举报
回复
select cast(大字段 as int)-cast(小字段 as int) from temp1
select cast(大字段 as decimal(18,2))-cast(小字段 as decimal(18,2)) from temp1
wzy_love_sly 2008-03-03
  • 打赏
  • 举报
回复
大爷的,先看看书
gagaxiaoyuer 2008-03-03
  • 打赏
  • 举报
回复
select * from temp1 cast(读数 as decimal(18,2)) 这样吗?
提示 AS 附近有错误
JiangHongTao 2008-03-03
  • 打赏
  • 举报
回复
selec 列 from 表 where isnumeric(列) = 0
找出不能转换的数据,查看是否包含全角,非数字字符等。
还有就是replace(列,' ','')去空格。
wzy_love_sly 2008-03-03
  • 打赏
  • 举报
回复
subtract,不是sql

select cast(字段 as int)-cast(字段 as int)
dawugui 2008-03-03
  • 打赏
  • 举报
回复
cast(col as decimal(18,2))
cast(col as int)
parss 2008-03-03
  • 打赏
  • 举报
回复
如果没有小数的数据就用整型了罗
JiangHongTao 2008-03-03
  • 打赏
  • 举报
回复
int 或numeric
gagaxiaoyuer 2008-03-03
  • 打赏
  • 举报
回复
因为现在表已经导进去了 用的nvarchar 改成numeric 说改不了

34,838

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧