RDBMS/🌈 MsSql
임시 테이블 선언 및 드랍(drop)
James Wetzel
2019. 7. 24. 12:06
테이블 변수 선언
if object_id('tempdb..#temp_data_table') is not null
drop table #temp_data_table
create table #temp_data_table (
arrived_set_dt datetime
, direct_use_yn char(1)
)
create nonclustered index TEMP_DATA_TABLE__ARRIVED_SET_DT on #temp_data_table (arrived_set_dt)
insert into #temp_data_table(
arrived_set_dt
, direct_use_yn
, inhousing_stat
, order_type
, order_no
)
select
xso.arrived_set_dt
, xso.direct_use_y
from test
-- 사용
if object_id('tempdb..#temp_data_table') is not null
drop table #temp_data_table
728x90
반응형