判断sql执行效率以及针对临时表的使用

时间:2021-09-01 14:33:26
/****** Script for SelectTopNRows command from SSMS  ******/

SET STATISTICS io ON
SET STATISTICS time ON
go
SELECT * FROM [TestPrint] WHERE ID IN (1,2,3,4,5,6,7,8,9,10);
go
SET STATISTICS profile OFF
SET STATISTICS io OFF
SET STATISTICS time OFF
go SET STATISTICS io ON
SET STATISTICS time ON
go
SELECT * FROM [TestPrint] WHERE ID BETWEEN '1' AND '10';
go
SET STATISTICS profile OFF
SET STATISTICS io OFF
SET STATISTICS time OFF
go select * into #tab from [TestPrint] where ID between '1' and '50000';
select * from #tab order by ID asc;
select name from tempdb.dbo.sysobjects where type='u' and name like '#%'
--truncate table ;(删除表)
go