waitfor的使用

 
create table my_test
(
	id int identity(1,1),
	[name] int
)
go
declare @theCount int
set @theCount=1
while @theCount<100
begin 
	insert into my_test values(@theCount)
	set @theCount=@theCount+1
	waitfor delay '00:00:05'
end


waitfor表示暂停后面的sql的执行

time 表示到时间以后在执行

而delay  每次执行延迟的时间

同时需要注意的是 执行结果它会在完成整个sql的执行以后才会进行返回。但是sql它已经在后台执行了,你直接是看不到执行状态的,它需要在执行完毕以后才会显示结果。查询sql完全看不到,而操作性的sql可以打开新的新的查询窗口对数据表进行查询就能看到了。

 

 

posted on 2011-09-28 14:24  叮叮猫的编程世界  阅读(309)  评论(0编辑  收藏  举报