Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Procedures and functions with cross-database dependencies Expand / Collapse
Author
Message
Posted Thursday, July 3, 2014 10:56 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Tuesday, October 28, 2014 2:16 PM
Points: 4, Visits: 17
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...
Post #1589041
Posted Thursday, July 3, 2014 11:58 AM This worked for the OP Answer marked as solution


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Yesterday @ 10:20 AM
Points: 12,927, Visits: 32,332
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

--There is no spoon, and there's no default ORDER BY in sql server either.
Actually, Common Sense is so rare, it should be considered a Superpower. --my son
Post #1589081
Posted Friday, July 4, 2014 2:24 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Tuesday, October 28, 2014 2:16 PM
Points: 4, Visits: 17
Excellent, that's just what I wanted to hear!
Post #1589233
Posted Friday, July 4, 2014 6:10 PM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: General Forum Members
Last Login: Yesterday @ 5:34 PM
Points: 35,609, Visits: 32,200
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."

(play on words) "Just because you CAN do something in T-SQL, doesn't mean you SHOULDN'T." --22 Aug 2013

Helpful Links:
How to post code problems
How to post performance problems
Post #1589452
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse