• Just a note on creating user-defined objects in master.

    I think this makes maintenance and disaster recovery more difficult. Since you didn't make this function a "true" system function, it might be better to have a separate DB if you have multiple objects you want to share in different databases. Now, if you want to make it a "true" system function, you need to add it to the system function schema like this:

    SP_CHANGEOBJECTOWNER 'fn_WorkDays','system_function_schema'

    That way you should be able to call it like any other built-in fn_* function. I don't suggest this a) for the above mentioned reason and b) I am told that SQL Server 2005 reinvents this wheel anew.

    --
    Frank Kalis
    Microsoft SQL Server MVP
    Webmaster: http://www.insidesql.org/blogs
    My blog: http://www.insidesql.org/blogs/frankkalis/[/url]