SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Procedures and functions with cross-database dependencies


Procedures and functions with cross-database dependencies

Author
Message
joshturnbull90
joshturnbull90
Forum Newbie
Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)

Group: General Forum Members
Points: 4 Visits: 33
Long story short - our company's primary operational database is poorly designed and has been poorly maintained in the past. We can't rely on the suppliers to improve things for our purposes so we're looking into developing a database containing objects that would act on the former database (e.g. cleanup procedures, additional data storage and reporting functions).

Would anyone know what the extent of performance costs is of using procedures, functions or views from one database on data from another if both databases are on the same server? Are there any reasons why this might be a horrible idea in general? I want to avoid creating objects in the existing database as it's already cluttered with hundreds of tables and thousands of SPs...
Lowell
Lowell
One Orange Chip
One Orange Chip (29K reputation)One Orange Chip (29K reputation)One Orange Chip (29K reputation)One Orange Chip (29K reputation)One Orange Chip (29K reputation)One Orange Chip (29K reputation)One Orange Chip (29K reputation)One Orange Chip (29K reputation)

Group: General Forum Members
Points: 29503 Visits: 39986
on the same server, i believe it's no problem; every query eventually gets resolved to all objects to thee part naming conventions...database.schema.object;

I have a system I babysit that we recently migrated to use Synonyms for the three part objects, to make it easier to build development vs QA vs production instances.

you can look at the execution plans of those kinds of multi database operations, there's nothing different than when all the objects are in the same database.

Lowell

--
help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

joshturnbull90
joshturnbull90
Forum Newbie
Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)

Group: General Forum Members
Points: 4 Visits: 33
Excellent, that's just what I wanted to hear!
Jeff Moden
Jeff Moden
SSC Guru
SSC Guru (90K reputation)SSC Guru (90K reputation)SSC Guru (90K reputation)SSC Guru (90K reputation)SSC Guru (90K reputation)SSC Guru (90K reputation)SSC Guru (90K reputation)SSC Guru (90K reputation)

Group: General Forum Members
Points: 90962 Visits: 41151
I absolutely agree with Lowell but let me give you another hint that will save much in the area of agony in the future....

Don't use anything more than the 2 part naming convention in any of your code. Use only the 2 part naming convention. If a table is in a different database, then create a synonym that's naming using 2 part naming to point to the object in the other database.

Why? First, it hurts nothing for performance. Second, it makes programming easier. Third, you won't have to change any of your code if you decide to move a table to different database or even rename the whole database. Instead you only need to change the synonym(s).

--Jeff Moden

RBAR is pronounced ree-bar and is a Modenism for Row-By-Agonizing-Row.
First step towards the paradigm shift of writing Set Based code:
Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column.
If you think its expensive to hire a professional to do the job, wait until you hire an amateur. -- Red Adair

Helpful Links:
How to post code problems
How to post performance problems
Forum FAQs
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search