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.
| 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 thisnow 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 thisselect * 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 |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-09-03 : 02:40:25
|
| Do you want to get city_code which are purely numbers?MadhivananFailing to plan is Planning to fail |
 |
|
|
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 typeif 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=0elseval='txt'endif like this is it possible |
 |
|
|
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. |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-09-03 : 05:03:46
|
| Note that isnumeric is not reliableselect isnumeric('12d1'),isnumeric('.'),isnumeric(','),isnumeric('$')MadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|
|
|