SqlServer临时表的应用
时间:2011-05-03 来源:陈高
1.1.1. 简介
drop table #temp1
1.1.2. 应用场景
1.1.3. 应用示例
DECLARE @T2 table(ProjectNo int,xl_Pressure nvarchar(200)); -- 压力
insert into @T2 (ProjectNo,xl_Pressure)
select a.ProjectNo,b.xl_Pressure from
(SELECT o_parentno as ProjectNo,o_projectno as TenderID FROM CDMS_Project
where o_type = 'TS') as a
select * from
(
SELECT B.ProjectNo,LEFT(UserList,LEN(UserList)-1) as xl_Pressure
FROM
(
SELECT ProjectNo, (SELECT xl_Pressure+'\' FROM @T2 WHERE ProjectNo=A.ProjectNo FOR XML PATH('')) AS UserList
FROM @T2 A GROUP BY projectno
) B
) as h on h.ProjectNo = A.o_projectno
1.1.4. 取得的成果
在应用临时表是应该充分考虑对内存的消耗,以便对系统的性能不会造成影响。
相关阅读 更多 +