My question is similar :)
I would like to use my function in selects, I would like to specify this function is deterministic, so that it does not need to compute the SQL for each row.
For example, the select below returns the same time in the first column for each row, but not in the 2nd column.
Is it possible to specify somewhere that the test() function should work like the plain getdate()? (I know I can save it into a variable, but that requires rewriting hundreds of queries, it's not enough to replace GETDATE() with dbo.GetCETDate() everywhere :) )
the test:
create function dbo.test() returns datetime
with schemabinding
as
begin
return getdate()
end
GO
SELECT OBJECTPROPERTY(OBJECT_ID('dbo.test'), 'IsDeterministic');
-- result is 0
GO
select GETDATE(), dbo.test() from BigTable