要求:将两个表中的Department放到一个表并去重后输出
sql语句:
if(object_id(N'tempdb..#tempTable') is not null)
drop table #tempTable--删除临时表
select Department into #tempTable from Cfg_DepartmentGroup--创建临时表并将Cfg_DepartmentGroup表中的Department列放到临时表中
insert into #tempTable select a.Department from Cfg_Department a--将Cfg_Department表中的Department列追加到临时表中
select distinct * from #tempTable--去重输出临时表