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 |
|
rajadadi
Starting Member
30 Posts |
Posted - 2010-05-03 : 04:50:18
|
| Actually database store Value is 2 but in front end it shows : Inservicebut i want to take report so i need function to convert that value to this string.these are the value 0,1,2,3these are front end value: Out of Service,Inservice,Hold,N/Aplease tell me the function to convert thisrajesh |
|
|
karthik_padbanaban
Constraint Violating Yak Guru
263 Posts |
Posted - 2010-05-03 : 04:55:11
|
| select case when column_name = 0 then 'Out of Service'when column_name = 1 then 'Inservice'when column_name = 2 then 'Hold'when column_name = 3 then 'N/A' end as [Column_name]from table_nameKarthikhttp://karthik4identity.blogspot.com/ |
 |
|
|
DBA in the making
Aged Yak Warrior
638 Posts |
Posted - 2010-05-03 : 08:27:47
|
You should have a lookup table, with the following values. Then join to that table. 0 Out of Service1 Inservice2 Hold3 N/A These items (Out of Service, Inservice, Hold, N/A) are data. Data is stored in tables, not in functions, queries, stored procs, etc.------------------------------------------------------------------------------------Any and all code contained within this post comes with a 100% money back guarantee. |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-05-03 : 09:46:56
|
| i would also second last suggestion as it gives you flexibility of adding new items as well as there mapping values without touching you code. Any addition would simply mean a new insert to lookup table rather than tweakung your code with CASE------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|
|
|
|