`
cd0281
  • 浏览: 119796 次
  • 性别: Icon_minigender_1
  • 来自: 厦门
社区版块
存档分类
最新评论

sql server 2005 递归查询

阅读更多
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go

/**
**
**author: zhyd
**date:20100331
**
**获取当前用户组织下的所有子组织(包括自己)
**/
 
  
ALTER proc [dbo].[SP_GET_OWNER_OFFICE](  
    @CREATE_OFFICE VARCHAR(100)
)  
AS 
BEGIN  
	with officeTemp(office_code)
	as
	(
		select office_code from sys_office where office_code = @CREATE_OFFICE
		union all
		select b.office_code from officeTemp a
		inner join sys_office b on b.supperior_office_code = a.office_code
		
	)

	select office_code from officeTemp
END  
  
  
  
  





  • 大小: 31.8 KB
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics