0

我有一个存储过程,它有一个 datetime var,它在 proc 的开头使用 GETDATE 设置,然后调用 MERGE 语句。

发生的事情是没有一个日期被盖章,而是日期定期更改。这是一个长期运行的过程。

有没有办法获得一个日期并在所有记录上盖章?

create proc MyProc as
declare @insertdate datetime
set @insertdate = getdate()
merge dbo.something as target
using (select col1,col2 from dbo.another) as source
on (target.col1 = source.col1 and target.col2 = source.col2)
when not matched by target
insert (col1, col2, insertdate) values (source.col1, souce.col2, @insertdate);
4

0 回答 0