I have a function similar to the following (similar in the way that it calls itself on some conditions):
Alter FUNCTION [dbo].[test] ( @x int )
RETURNS NVARCHAR(10)
WITH SCHEMABINDING
AS
BEGIN
RETURN case when @x<10 then [dbo].test(@x+1) else 'OK' end
end
When I execute to alter the function and add "WITH SCHEMABINDING" I get
Msg 4512, Level 16, State 3, Procedure test, Line 9
Cannot schema bind function 'dbo.test' because name 'dbo.test' is invalid for schema binding. Names must be in two-part format and an object cannot reference itself.
Why is that ? and how can i solve it ? .... Again, please note that the function calls itself on certain condition.