Click here to Skip to main content
15,895,746 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I have a SQL query where I would like to know is it possible to convert line number which in my result shows 0,1,2,3 or 4 on each column.
is it possible to show something like this?

0 =Write off at Customer
1 =Return to Original GRN
2 =Refund Only
3 =Return to New GRN
4 =Reverse Invoice
SQL
SELECT     CreditRequest.TheirReference, CreditRequestLine.LineType, CreditRequest.CreditRequestNumber
FROM         CreditRequest INNER JOIN
                      CreditRequestLine ON CreditRequest.CreditRequestID = CreditRequestLine.CreditRequestID

Line ID
2
3
1
2
4
Posted
Updated 31-Mar-15 0:59am
v2
Comments
King Fisher 31-Mar-15 6:59am    
what do you mean numbers to text?not clear .
Manoj K Bhoir 31-Mar-15 7:05am    
Your question is not clear. Please use Improve Question.
Manoj K Bhoir 31-Mar-15 7:06am    
If you just want to convert number into text then you can use CASE Statement.
King Fisher 31-Mar-15 9:28am    
I think you want to replace the text instead of numbers,Is it?

1 solution

Yes.
The best way to do it is to set up a separate table:
C#
ResultCodes
ResId (INT)  Desc(NVARCHAR)
0            Write off at Customer
1            Return to Original GRN
2            Refund Only
3            Return to New GRN
4            Reverse Invoice
You then use an SQL JOIN to return the data
C#
SELECT a.Customer, b.Desc FROM MyTable a
JOIN ResultCodes b
ON a.Res=b.ResId

You can probably combine that with your existing query pretty easily - I have no idea what field of yours is what so I can't do that for you!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900