0

Let say I have table

 Payments

Id int autoincement
Status int

and my query is :

select id, status from payments

but I wanna convert status to enum.

0 is unpaid
1 is paid.

so result should look like:

1 paid
2 unpaid
3 paid
...

I need this conversion because I use

XmlReader reader = cmd.ExecuteXmlReader();
oc.LoadXml("<results></results>");

XmlNode newNode = doc.ReadNode(reader);

while (newNode != null)
{
  doc.DocumentElement.AppendChild(newNode);
  newNode = doc.ReadNode(reader);
}

and then I save this xml and opening it by excel, and statuses should be friendly for user.

1 Answer 1

4
select Id,
case status when 0 then 'unpaid' when 1 then 'paid' else 'unknown' end as Status
from Payments
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.