임시테이블을 사용하고 난 후에
예외처리부분에서 사용하면 유용하다.
-- OBJECT_ID() 확인후 있으면 테이블 삭제
IF OBJECT_ID('tempdb..#tblTemp') IS NOT NULL
drop table #tblTemp
-- 확인
Select table_catalog, table_schema, table_name, table_type
from tempdb.information_schema.tables
-- tempdb.sys.objects
select *
from tempdb.sys.objects
where name like '#aaa%'
예외처리부분에서 사용하면 유용하다.
-- OBJECT_ID() 확인후 있으면 테이블 삭제
IF OBJECT_ID('tempdb..#tblTemp') IS NOT NULL
drop table #tblTemp
-- 확인
Select table_catalog, table_schema, table_name, table_type
from tempdb.information_schema.tables
where table_name like '#temptable%'
-- tempdb.sys.objects
select *
from tempdb.sys.objects
where name like '#aaa%'
[출처] 임시테이블 존재여부 확인하기, 삭제하기|작성자 무지개
'Programming > Database' 카테고리의 다른 글
Linked Server 원격프로시저 호출 (0) | 2009.05.29 |
---|---|
트랜잭션 로그 줄이기 (0) | 2009.05.11 |
SQL 2005 64bit에서 32bit의 SQL2000이나 SQL7.0으로 링크드 서버 연결할때 오류 대처법 (0) | 2009.02.05 |
특정 프로시저와 연관있는 객체 찾기 (0) | 2009.01.23 |
특정객체 포함하는 프로시저 찾기 (1) | 2009.01.23 |