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 |
|
yahazim
Starting Member
13 Posts |
Posted - 2002-05-14 : 16:00:23
|
| I have multiple FLAG fields that use SMALLINT datatype with either "-1" or "0" as the possible inputted data.I have numerous stored procedures that return the results of those FLAG fields. However I want the user of the database to be able to read those results as something more meaningful than "-1" or "0".I want to return the "-1" as YES and the "0" as NO.How can I convert this in the stored procedure using T-SQL instead of joining the table to another?Thank you in advance.Jim |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2002-05-14 : 16:07:39
|
| SELECT CASE Flag1 WHEN -1 THEN 'Yes' WHEN 0 THEN 'No'ENDFROM FlagTableIf you are certain that only -1 and 0 are in those columns, then this will work too:SELECT CASE Flag1 WHEN -1 THEN 'Yes' ELSE 'No'ENDFROM FlagTableConsidering that a smallint is two bytes, and if you don't need anything other than yes or no, why not just convert the column to a varchar(3) and actually store "yes" or "no"? Or, make it a char(1) column with "Y" or "N" values...you'd save space AND eliminate the need to do the conversion. |
 |
|
|
yahazim
Starting Member
13 Posts |
Posted - 2002-05-14 : 20:45:38
|
| THANK YOU.] |
 |
|
|
|
|
|