日期:2014-05-18 浏览次数:20430 次
IF OBJECT_ID('Customers','U') IS NOT NULL DROP TABLE Customers CREATE TABLE Customers ( CustomerID INT primary key identity(1,1), CustomerNumber CHAR(4), CustomerName VARCHAR(50), CustomerCity VARCHAR(20) ) GO TRUNCATE table Customers GO ----清除干扰查询 DBCC DROPCLEANBUFFERS DBCC FREEPROCCACHE SET STATISTICS IO ON; SET STATISTICS TIME ON; GO DECLARE @d Datetime SET @d=getdate(); declare @i int=1 while @i<=10000 begin INSERT INTO Customers (CustomerNumber, CustomerName, CustomerCity) SELECT REPLACE(STR(@i, 4), ' ', '0'),'Customer ' + STR(@i,6), CHAR(65 + (@i % 26)) + '-City' set @i=@i+1 end select [语句执行花费时间(毫秒)]=datediff(ms,@d,getdate()) SET STATISTICS IO OFF ; SET STATISTICS TIME OFF; GO