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)
 using isnumeric in where

Author  Topic 

san79
Starting Member

42 Posts

Posted - 2009-09-03 : 02:22:28
hi all,
i have got a table (which is given to me by my client and i have to live with that) one of the column contains both numeric and character
say the field name is city_code the sample value is like 10,'WI',21, 'TN' like this
now i am designing a web application which has a drop down list which contains name of the cities for text and the value has value fields.
i would like to retrieve the value from the table like this
select * from tbl1 where if (isnumeric(city_code) ,[value fld],[text fld]) how to do that.
i am stumped any help will be greatly appreciated.
the table is in sql 2005

Nageswar9
Aged Yak Warrior

600 Posts

Posted - 2009-09-03 : 02:37:27
Hi,
select * from tbl1 where isnumeric(city_code) = 0
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-09-03 : 02:40:25
Do you want to get city_code which are purely numbers?

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

san79
Starting Member

42 Posts

Posted - 2009-09-03 : 03:14:48
no , actually i want to send the value based on the current fields data type
if it is in number i will send the pass the value from the dropdownlist if it is text i will pass text from ddl hope i am clear. like a if case
if isnumeric() then
val=0
else
val='txt'
endif
like this is it possible
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2009-09-03 : 04:29:35
One output column can not have different data types in a record set.
So your solution my be to output numeric values also as character type.


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-09-03 : 05:03:46
Note that isnumeric is not reliable
select isnumeric('12d1'),isnumeric('.'),isnumeric(','),isnumeric('$')

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -