如何使用临时表
野鼻孔 2016-04-13 11:14:55 大神们好,我想咨询下如何使用临时表,我的逻辑是要更新临时表中的一些字段,做报表,然后使用完再清楚临时表,不知道如何操作。
我的理解如果新建了个临时表之后,用了select语句,再drop临时表,那么select语句显示的数据还会有吗?
求更正代码: 我用了With取了一些数据,然后select with的数据
select * into #Temp_DiaryNotes from A_Diary_Notes
update #Temp_DiaryNotes set Diary_Note = REPLACE(Diary_Note,'"','''''')
WITH TA14 as (select Application_Number,Max(diary_date + Diary_Time) as detailtime,Diary_Note from #Temp_DiaryNotes(nolock)
where Diary_Type='M' and Diary_Note not like 'Reassign application%' and (User_Id in (select User_Id from Security where Profile_Name='FRAUD_REVIEWER')
or User_Id in (select User_Id from Security where Profile_Name='FRAUD_MANAGER')) group by Application_Number,Diary_Note)
select * from TA14
drop table #Temp_DiaryNotes
WIth的数据为
Application_Number detailtime Diary_Note
1000177264 2016-04-12 00:00:40.000 看看你
1000182136 2016-04-12 23:26:25.000 看看我
1000182136 2016-04-12 23:25:01.000 不让看
1000177264 2016-04-12 00:01:49.000 看看他
求大神们帮帮忙