Вопрос

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