سؤال

What happens if use SYSUTCDATETIME() in a view? Will the view work correctly? When will it execute the SYSUTCDATETIME function?

For instance I ve created a view from the following select

SELECT * FROM dbo.contracts
WHERE (contract_start < SYSUTCDATETIME()) AND (contract_end > SYSUTCDATETIME())
هل كانت مفيدة؟

المحلول

It (SYSUTCDATETIME()) will return the value (as any other function) at the time of execution of the view.

Execute this query several time and see for yourself

SELECT *, SYSUTCDATETIME() sysutcdatetime FROM contracts
WHERE (contract_start < SYSUTCDATETIME()) AND (contract_end > SYSUTCDATETIME());

SQLFiddle

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top