UDF available to many databases

Posted on 2007-08-07
Last Modified: 2010-03-19
I have a sql function which I would like many databases to have access to.  
What is the best way to do this?  Will putting the function in the Master database make it available to all other databases?

Question by:KimberleyY
    LVL 42

    Accepted Solution

    It's available to other databases regardless of which database it is stored in. Personally, I would NOT put it in master just because that is a system database that I don't like to alter.  

    I know this is not what you want to hear, but if the function is NOT application specific, then I would probably follow microsoft's precedcent and put a copy in every database to facilitate portability.  Or at least I would put a synonym for it in every database.  Then things won't go haywire when you start moving databases around.  You can put the original in the model database to facilitate distribution.

    If the function is application specific, then I would put it on every database for that application.  Create a synonym for it on every other database that needs to access it.

    Author Comment

    How do you know what I want to hear? ;>) Thanks this answer was just fine.  

    Thanks for you help!

    LVL 42

    Expert Comment

    >How do you know what I want to hear?

    The same way you can "hear" what I've  typed?

    Good luck

    Featured Post

    Free Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Join & Write a Comment

    I've encountered valid database schemas that do not have a primary key.  For example, I use LogParser from Microsoft to push IIS logs into a SQL database table for processing and analysis.  However, occasionally due to user error or a scheduled task…
    Introduction: When running hybrid database environments, you often need to query some data from a remote db of any type, while being connected to your MS SQL Server database. Problems start when you try to combine that with some "user input" pass…
    how to add IIS SMTP to handle application/Scanner relays into office 365.
    This video discusses moving either the default database or any database to a new volume.

    734 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now