开发者

Converting output of sql query

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 lo开发者_如何学Gook 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.


select Id,
case status when 0 then 'unpaid' when 1 then 'paid' else 'unknown' end as Status
from Payments
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜