WITH DEPTINFO(DeptCode, UpperDeptCode) AS
(         
	SELECT DeptCode, UpperDeptCode
    FROM dbo.tb_DeptList
    WHERE DeptCode ='A001'
    UNION ALL
    SELECT A.DeptCode, A.UpperDeptCode
    FROM DEPTINFO AS A
    JOIN dbo.tb_DeptList AS B
    ON A.DeptCode = B.UpperDeptCode  
)
SELECT DeptCode, UpperDeptCode
FROM DEPTINFO

'DataBase' 카테고리의 다른 글

SQL Query Tip  (0) 2011.02.13
Windows Server 2008 R2에서 SQL Server 2008 원격 접속 허용하기  (1) 2010.06.25
SQL index 초기화  (0) 2009.11.25
새로운 SQL 잘라내기 공격 및 대처 방법  (0) 2009.07.06
MS-SQL 트리거  (0) 2009.07.03

SQL index 초기화 쿼리문
DBCC checkident('테이블명', reseed, 0)

+ Recent posts