문제

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