开发者

MS SQL 2005: Any way to temporarily set the system date for a T-SQL script to a different date?

We have a bunch of T-SQL scripts dependent on today's date and when they run. If one doesn't run on the week it should, we end up temporarily setting the system time a day before, run the script, then set i开发者_JAVA百科t back.

Is there anyway to temporarily set the system date for a script without changing the original script, like when you execute it or only for that session?


You could store the actual date in a table / temp table. THen retrieve or update that date rather then making a call to GetDate().


I've found an answer by someone else, here I share it: "The date is tied to the OS date and time. See here: http://msdn.microsoft.com/en-us/library/ms188383.aspx".

You could refer to this other question Simulate current date on a SQL Server instance?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜