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 |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2003-06-05 : 08:35:37
|
| Rajdett writes "Dear Sir,I am using asp.net with database sql 7.0 .I am retreiving data from a table royThis table has a column called DataValue which has data like 0-1-2I have to display data in datagrid(asp.net) on condition If 0 Display InclusiveIf -1 Display Not ApplicableIf -2 Display As ApplicableI want to know how to write If Else condition with sql query to display this in a asp.net Datagrid.Thanks" |
|
|
Merkin
Funky Drop Bear Fearing SQL Dude!
4970 Posts |
Posted - 2003-06-05 : 08:53:53
|
Roy is a good name for a table.You would use a case statement for this :SELECTCASE DataValue WHEN 0 THEN 'Inclusive'WHEN -1 THEN 'Not Applicable'WHEN -2 THEN 'Applicable' END as DataValueTextFROM MyTableRoy Damian |
 |
|
|
mtomeo
Starting Member
30 Posts |
Posted - 2003-06-05 : 08:55:23
|
I think this is what you are looking for...Case works better than If...Then in this situation. You can also add an "Else" condition for all other values. Note: I'm assuming DataValue is numeric. Add quotes if it's a string. Select Case DataValue When 0 Then 'Inclusive' When -1 Then 'Not Applicable' When -2 Then 'As Applicable' EndFrom roy |
 |
|
|
|
|
|