---
title: "sqlserver 中 case 的用法"
author: "firefly_liu"
date: "2008-08-06T14:31:48Z"
tags: []
slug: "sqlserver-case"
draft: false
lastmod: "2008-08-06T14:31:48Z"
id: 225010
url: "https://firefly-liu.iteye.com/blog/225010"
---

```
select field1,
(case
when condition then dosomthing
when condition then dosomthing
else dosomthing
end) fieldname
from tablename

--或者在products、tigger和function中也可以使用
```