select * from book where price = CASE WHEN ISNUMERIC(x)=1 THEN CAST(X AS NUMERIC(10,2) ELSE -1 END
select * from book where charindex('0',price) or charindex('1',price)....or charindex('9',price)
好像应该: select * from book where CASE WHEN ISNUMERIC(price)=1 THEN CAST(price AS NUMERIC(10,2) ELSE -1 END=X 我想只查询带数字的价格,“价格面议”之类的中文字符就不显示了。select * from book where ISNUMERIC(price)=1
select Price from book where charindex('0',Price) or charindex('1',Price) or charindex('2',Price) or charindex('3',Price) or charindex('4',Price) or charindex('5',Price) or charindex('6',Price) or charindex('7',Price) or charindex('8',Price) or charindex('9',Price)服务器: 消息 156,级别 15,状态 1,行 2 在关键字 'or' 附近有语法错误。
select * from book where price like '[0-9]' 只显示出了'0','1'
declare @ta table(id varchar(20)) insert @ta select 123123564564 union all select '中国人万岁' union all select 'adfadfa1213'union all select 15.6select * from @ta where isnumeric(id)=1select * from @ta where id not like '%[^.0-9]%' (所影响的行数为 4 行)id -------------------- 123123564564 15.6(所影响的行数为 2 行)
declare @ta table(id varchar(20)) insert @ta select 123123564564 union all select '中国人万岁' union all select 'adfadfa1213'union all select 15.6 select * from @ta where id like '%[0-9]%'(所影响的行数为 4 行)id -------------------- 123123564564 adfadfa1213 15.6(所影响的行数为 3 行)这是查询字段有数字的字段,如果只显示字段中的数字,要写一个函数才行
declare @str nvarchar(300) set @str = N'dafjzdnldnmfads$' select case when patindex('%[0-9,$,¥]%',@str)>0 then '包含' else '不包含' end
select * from book where CASE WHEN ISNUMERIC(price)=1 THEN CAST(price AS NUMERIC(10,2) ELSE -1 END=X
我想只查询带数字的价格,“价格面议”之类的中文字符就不显示了。select * from book where ISNUMERIC(price)=1
确定表达式是否为一个有效的数字类型。语法
ISNUMERIC ( expression )参数
expression要计算的表达式。返回类型
int注释
当输入表达式得数为一个有效的整数、浮点数、money 或 decimal 类型,那么 ISNUMERIC 返回 1;否则返回 0。返回值为 1 确保可以将 expression 转换为上述数字类型中的一种。
where charindex('0',Price) or
charindex('1',Price) or
charindex('2',Price) or
charindex('3',Price) or
charindex('4',Price) or
charindex('5',Price) or
charindex('6',Price) or
charindex('7',Price) or
charindex('8',Price) or
charindex('9',Price)服务器: 消息 156,级别 15,状态 1,行 2
在关键字 'or' 附近有语法错误。
只显示出了'0','1'
insert @ta
select 123123564564 union all
select '中国人万岁' union all
select 'adfadfa1213'union all
select 15.6select * from @ta where isnumeric(id)=1select * from @ta where id not like '%[^.0-9]%'
(所影响的行数为 4 行)id
--------------------
123123564564
15.6(所影响的行数为 2 行)
insert @ta
select 123123564564 union all
select '中国人万岁' union all
select 'adfadfa1213'union all
select 15.6
select * from @ta where id like '%[0-9]%'(所影响的行数为 4 行)id
--------------------
123123564564
adfadfa1213
15.6(所影响的行数为 3 行)这是查询字段有数字的字段,如果只显示字段中的数字,要写一个函数才行
set @str = N'dafjzdnldnmfads$'
select case when patindex('%[0-9,$,¥]%',@str)>0 then '包含' else '不包含' end