SQLSERVER store procedure 临时表

有些时候显示重复数据时,使用:

select * from [表A] where id in (select id from [表A] group by id having count(id) >1 )

 

但有些时候表A过大或者逻辑复杂。显示数据时,会造成性能的影响,这时你就可以使用临时表:
 
1) create table #temp(
XXX ,
XXX)

2)insert into #temp(XXX,XXX)
select xx from xxx

3)#temp //灵活使用临时表
4)drop #temp;

 

posted @ 2018-02-27 17:34  西番莲果汁  阅读(218)  评论(0编辑  收藏  举报