Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Other SQL Server Topics (2005)
 Calling a user defined function without Schema Pre

Author  Topic 

JerinMathew
Starting Member

2 Posts

Posted - 2010-09-20 : 10:36:49
Hi ,

I created a LOGIN User U1 and CREATED a database user DU1 and linked him with the Login User and I created a schema say S1 and set S1 as the default schema for DU1 .

I have a stored Procedure and a userdefined function inside S1 . I logged in as the Login user, I can execute that procedure directly without any schema prefix but I cannot call a user defined function F1 directly (without schema prefix) . it throws an exception
"function name is not a recognized built-in function name".


How can i call a UDF directly with out a schema prefix

THE STEPS I FOLLOWED ARE :
-----------------------------

--Login User Creation
CREATE LOGIN S11 WITH PASSWORD = 'Passw@rd!';
--Database User Creation and assign to default schema
CREATE USER S11 FOR LOGIN S11 WITH DEFAULT_SCHEMA = S2;
--Giving User Privilege
EXEC sp_addrolemember db_owner,'S11'

--Calling Procedure
Execute as user = 'S11'
exec MYSTOREDPROCEDURE1 -- Working fine
USERDEFINEDFUNCTION() -- Not working throws error

HOW CAN I CALL A UDF WITHOUT SCHEMA PREFIX

robvolk
Most Valuable Yak

15732 Posts

Posted - 2010-09-20 : 11:46:48
You could try creating a synonym for the function under S11's default schema, but the better option is to specify the schema every time.
Go to Top of Page
   

- Advertisement -