Not sure if this helps, but if you add it to Model I believe it will be created in all new databases you create on that server. ( and I think you could also script the UDF for adding to already existing databases )
>The UDF needs to get it's data from the current database and calling the UDF with Master in front will cause the UDF to try and get the data from Master.
>
>-Dan
>
>>SELECT Master.dbo.MyFunc()
>>
>>>Borislav,
>>>
>>>Thanks for the response. I added it to the master DB and I am still getting the Invalid object name when trying to use it.
>>>
>>>-Dan
>>>
>>>>>I would like to create a public UDF and use it in a SELECT statement. The UDF works correctly when it's located in the same database but I don't want to have to update multiple databases if the UDF ever changes. I have created a UDF and issued -
>>>>>
>>>>>
>>>>>GRANT Execute ON myudf to public
>>>>>
>>>>>
>>>>>How can I then use this UDF in a SELECT in a different database without referencing the database that the UDF is in? I get the error "Invalid object name 'dbo.myudf' when executing -
>>>>>
>>>>>
>>>>>SELECT dbo.myudf()
>>>>>
>>>>>
>>>>>TIA
>>>>>
>>>>>-Dan
>>>>
>>>>Why not create it in Master DB?
Charles Hankey
Though a good deal is too strange to be believed, nothing is too strange to have happened.
- Thomas Hardy
Half the harm that is done in this world is due to people who want to feel important. They don't mean to do harm-- but the harm does not interest them. Or they do not see it, or they justify it because they are absorbed in the endless struggle to think well of themselves.
-- T. S. Eliot
Democracy is two wolves and a sheep voting on what to have for lunch.
Liberty is a well-armed sheep contesting the vote.
- Ben Franklin
Pardon him, Theodotus. He is a barbarian, and thinks that the customs of his tribe and island are the laws of nature.