日期:2014-05-18 浏览次数:20755 次
use tempdb
go
create proc p_test
@id datetime output
as
set @id = (select dateadd(day,2,getdate()))
go
declare @id datetime
set @id = (select getdate())
select @id
WAITFOR DELAY '00:00:05'
exec p_test @id output
select @id
go
drop proc p_test
go
use tempdb
go
create proc p_test
@id datetime output
as
set @id = dateadd(day, 2, isnull(@id,getdate())) -- @id传入时间,NULL取getdate()
go
declare @id datetime
set @id = (select getdate())
select @id
WAITFOR DELAY '00:00:05'
exec p_test @id output
select @id
go
drop proc p_test
------解决方案--------------------
getdate() 是不确定函数。两次执行值是不一样的,所以delay 的5秒在俩面有体现。
getdate()后一般直接存储到变量里面使用。LZ这个
WAITFOR DELAY '00:00:05'
exec p_test @id output
等待5秒后,再次的getdate()肯定是跟前面的不一样了。