October 9, 2003 at 4:16 pm
I want to create a user defined function available to all databases.If you have any idea's please let me know.
October 9, 2003 at 5:35 pm
Must be in master, prefaced with "fn_" and added to system schema, e.g.:
USE master
go
CREATE FUNCTION fn_Pad(@i bigint, @p tinyint)
RETURNS varchar(20)
AS
BEGIN
RETURN RIGHT(REPLICATE('0',@p) + CAST(@i AS varchar(20)),@p)
END
go
sp_changeobjectowner 'fn_Pad','system_function_schema'
go
Removal is also tricky:
USE master
go
sp_configure 'allow updates',1
go
RECONFIGURE WITH OVERRIDE
go
DROP FUNCTION system_function_schema.fn_Pad
go
sp_configure 'allow updates',0
go
RECONFIGURE WITH OVERRIDE
go
--Jonathan
--Jonathan
October 9, 2003 at 5:45 pm
It doesn't matter where you create the function. You can specify the database name when you call the function.
eg: MyDb.dbo.MyFunction
Hope this helps
Phill Carter
--------------------
Colt 45 - the original point and click interface
--------------------
Colt 45 - the original point and click interface
October 10, 2003 at 7:56 am
Jonathan,
Thanks, it worked for me. But is it compatable for all versions?.
October 10, 2003 at 8:04 am
quote:
Jonathan,Thanks, it worked for me. But is it compatable for all versions?.
All versions that support UDFs. That would be SQL Server 2000.
--Jonathan
--Jonathan
October 14, 2003 at 7:44 am
Jonathan,
If i want edit that what is the procedure.
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply