December 19, 2012 at 9:30 am
Hi Friends,
I need to create a global function that can access directly with 'dbo' schema in all DB's.
Is it possible? if yes then please suggest with t-sql statements.
Regards,
Shubham Saxena
December 19, 2012 at 10:01 am
It's not exactly possible, but it can kind of be done.
The way I do it is create a database called Common, then use that as a library for functions, data, etc., that are used by many/all databases on a server.
Things like a table of US states and Canadian provinces, a table of countries (including ISO-3 codes for them), and a table of languages (ISO-3 again), a Numbers table, a Calendar table, and sometimes a few other things as well. Depends on the company I'm building it for. Some like US Zip codes in there, some don't, for example. Haven't run into it yet, but international phone codes, or US area codes, or something like that, might be useful for some companies.
Then, you can create a synonym in each of your user databases, which points to the appropriate object in the Common database. If you put the list of synonyms into the model database (system DBs), then new databases will automatically have them built in.
Very handy technique.
Make sense?
- Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
Property of The Thread
"Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply