---
title: "SQL脚本片段收藏"
author: "meetrice"
date: "2010-02-23T17:33:00Z"
tags: ["C", "C#", "C++", "SQL", "脚本"]
categories: ["数据库"]
slug: "sql"
draft: false
lastmod: "2010-02-23T17:33:00Z"
id: 600927
url: "https://meetrice.iteye.com/blog/600927"
---

SQLSERVER 脚本
1.自关联字段键值翻译：
select a.name,case when a.location='T' then '顶部显示' when a.location='L' then '左侧显示' when a.location='R' then '普通栏目' else '上方' end as locationname,c.name as parent,  b.Dept from ((sitecolumn a left outer join organization b on a.dept = b.id ) left outer join sitecolumn c on a.parent =c.id  and c.dept = 0 )    