Is there a way to call a User defined function without using "dbo." before the function name and parameters?
Using:
SELECT USERFUNCTION(PARAM1, PARAM2, PARAM3, PARAMN)
instead of:
SELECT dbo.USERFUNCTION(PARAM1, PARAM2, PARAM3, PARAMN)
This isn't possible for the SELECT
syntax. BOL States: "Scalar-valued functions must be invoked by using at least the two-part name of the function"
This syntax works however.
CREATE FUNCTION USERFUNCTION
(@p INT)
RETURNS INT
AS
BEGIN
RETURN (2)
END
GO
DECLARE @rc INT
EXEC @rc = USERFUNCTION 1
SELECT @rc
It is best practice to always explicitly schema qualify objects you are referencing anyway though to avoid some overhead for resolving the schema (and avoid the possibility that the schema cannot be resolved implicitly or is resolved in a way that is undesired)