[英]How to select numeric value from nvarchar column in sql server?
I have table like 我有像桌子
Create table Producttbl ( sno nvarchar(100),sname nvarchar(200),price nvarchar(100))
Values are 值是
sno sname price
1 aaa 1.50
2 ccc 5.30
abc xxx abc
3 dsd kkk
nn dss 5.1
Price column is nvarchar
it accept all kind of data like string or numeric. Price列是
nvarchar
它接受所有类型的数据,例如字符串或数字。
From that table, I want to select results like this: 我要从该表中选择如下结果:
sno sname price
1 aaa 1.50
2 ccc 5.30
Please help me. 请帮我。
You presumably want sno
values which consist of digits and only digits (otherwise, you need to specify which "numeric" types you wish to accept): 您大概想要由数字和仅数字组成的
sno
值(否则,您需要指定要接受的“数字”类型):
select * from ProductTbl where sno not like '%[^0-9]%'
We use a double negative check, to exclude sno
values which contain a non-digit character. 我们使用双重否定检查,以排除包含非数字字符的
sno
值。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.