Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
I'm trying to get results in a query where a field contains only one decimal point. It's an odd implementation, so I won't even get into that... what I'm trying to do is return all results that only have one decimal point.Example:
Id decimal1 1.02 1.1 3 1.1.04 1.1.15 2.2.2.2select * from tablewhere ISNUMERIC(decimal) <> 0
In theory, this should work, but I want to get your opinions on this... is ISNUMERIC the right way to do this?
vijayisonly
Master Smack Fu Yak Hacker
1836 Posts
Posted - 2010-03-05 : 14:16:24
Try this? Making use of Parsename function
declare @t table (Id int ,[decimal] varchar(10))insert @tselect 1, '1.0'union all select 2, '1.1 'union all select 3, '1.1.4'union all select 4, '1.1.1'union all select 5, '2.2.2.2'
Query
select * from @twhere parsename([decimal],3) is null
EDIT : However, if you have any records with no decimal at all, it will select that record too.