SQLUSA

Microsoft SQL Server 2000 Best Practices

How to construct a delay loop for simulation?

 

The following script can be used to create delay between statements for simulation purposes. The example creates a delay averaging 3 milliseconds:

 

declare @ms int, @delay int
set @delay = 3
while (2>1)
begin
select @ms=datepart(ms,getdate())
if (@ms % @delay = 0) break
end

 

 

American Standard in SQL Server Training
 
SQLUSA.com Home Page