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.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 isnumeric

Author  Topic 

soorajtnpki
Posting Yak Master

231 Posts

Posted - 2008-12-17 : 06:39:16
hi all,

select isnumeric('2d4') returns 1.

but the required o/p is 0


why is this?


tanx in advance...

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-12-17 : 06:43:48
because its a valid numeric format.The d is used to denote a float double precision.
Go to Top of Page

soorajtnpki
Posting Yak Master

231 Posts

Posted - 2008-12-17 : 07:19:03
ok,

how do we tackle this situation ?
how can i use this function in queries ..
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-12-17 : 07:22:18
quote:
Originally posted by soorajtnpki

ok,

how do we tackle this situation ?
how can i use this function in queries ..


you need to write your own function if you want numeric alone or use regular expressions.
Once such custom function can be found below

http://sqlblogcasts.com/blogs/madhivanan/archive/2007/08/27/enhanced-isnumeric-function.aspx
Go to Top of Page

soorajtnpki
Posting Yak Master

231 Posts

Posted - 2008-12-17 : 08:06:31
ok tanx visakh,
so moral is dont use isnumeric in queries, am i right?
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-12-17 : 08:18:55
quote:
Originally posted by soorajtnpki

ok tanx visakh,
so moral is dont use isnumeric in queries, am i right?


nope...not always right. it depends on reqmnt. if you want numbers alone then dont use it. but if purpose is to look for valid numeric formats, then its still the best choice.
Go to Top of Page

soorajtnpki
Posting Yak Master

231 Posts

Posted - 2008-12-17 : 08:56:48
ok tanx
Go to Top of Page
   

- Advertisement -