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
 Transact-SQL (2005)
 Calling a scalar function without schema prefix

Author  Topic 

rohan_man
Starting Member

8 Posts

Posted - 2009-04-07 : 21:01:04
Hi,

I have a simple scalar function.

CREATE FUNCTION [dbo].[to_date]
(@datestring varchar(30), @formatstring varchar(30))
RETURNS datetime

AS

BEGIN

RETURN convert(datetime,@datestring,120)

END

To execute it, I have been using
select dbo.to_date('12-oct-2003 3:45:22','')

Is there a way to create this function so that it can be called without the schema prefix?
select to_date('12-oct-2003 3:45:22','')

Or is there some place you can create global functions where you just need to call the function name?

Any help will be appreciated.

Cheers
Rohan


sunitabeck
Master Smack Fu Yak Hacker

5155 Posts

Posted - 2009-04-07 : 22:14:01
You always have to prefix the udf name with the schema name - unless invoked as a stored procedure as in
exec to_date '12-oct-2003 3:45:22',''
Go to Top of Page

rohan_man
Starting Member

8 Posts

Posted - 2009-04-15 : 03:23:57
Thanks for that. That's what I'd heard and read, but I was hoping that it could be done somehow.
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-04-15 : 03:47:15
Even if you create a synonym for the function you still need to prefix the synonym with owner.



E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page
   

- Advertisement -