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


Cross-database joins...


Cross-database joins...

Author
Message
McDavis
McDavis
SSC Veteran
SSC Veteran (203 reputation)SSC Veteran (203 reputation)SSC Veteran (203 reputation)SSC Veteran (203 reputation)SSC Veteran (203 reputation)SSC Veteran (203 reputation)SSC Veteran (203 reputation)SSC Veteran (203 reputation)

Group: General Forum Members
Points: 203 Visits: 5
Hi,
I'm in need of some advise on cross-database joins, i.e. is it possible? What are the performamce implications? Is there a better way to achieve the following?:

I'm developing an online forum as an additional service for an established group of users, but for political reasons I'm not able to modify the database that contains the users login credentials. Therefore, I currently have two databases (one containing user accounts, the other containing forum threads/messages/etc.) on the same physical MS SQL 2K server.

When displaying the forum messages, I need to also display information that resides in the other database (name, address, etc. of the poster). How do I go about this? Is it possible to do a cross-database join in this manner?

Any suggestions would be most appreciated.
Thanks.



noeld
noeld
SSCrazy Eights
SSCrazy Eights (9.6K reputation)SSCrazy Eights (9.6K reputation)SSCrazy Eights (9.6K reputation)SSCrazy Eights (9.6K reputation)SSCrazy Eights (9.6K reputation)SSCrazy Eights (9.6K reputation)SSCrazy Eights (9.6K reputation)SSCrazy Eights (9.6K reputation)

Group: General Forum Members
Points: 9568 Visits: 2048
Yes.

You can use 3 part Name like [DBname].[tableName].[Column] on the FROM Clause, but you must be aware about the crossdatabase ownership change. If all aobjects are ownned by dbo and NO user has db_ower priviledges then is not a big deal (If you are on SP3a make sure to enabled it) but if the above is not true check all the implications before you jump in!

HTH


* Noel
McDavis
McDavis
SSC Veteran
SSC Veteran (203 reputation)SSC Veteran (203 reputation)SSC Veteran (203 reputation)SSC Veteran (203 reputation)SSC Veteran (203 reputation)SSC Veteran (203 reputation)SSC Veteran (203 reputation)SSC Veteran (203 reputation)

Group: General Forum Members
Points: 203 Visits: 5
Thank you, I'll give that a go.

For reference, all objects are owned by dbo and the account being used has only public, db_datareader, db_datawriter... but what would happen/be the difficulty if that was not the case?



noeld
noeld
SSCrazy Eights
SSCrazy Eights (9.6K reputation)SSCrazy Eights (9.6K reputation)SSCrazy Eights (9.6K reputation)SSCrazy Eights (9.6K reputation)SSCrazy Eights (9.6K reputation)SSCrazy Eights (9.6K reputation)SSCrazy Eights (9.6K reputation)SSCrazy Eights (9.6K reputation)

Group: General Forum Members
Points: 9568 Visits: 2048
with crossdatabase ownership enable a user that has db_owner permission on database "A" will automatically have db_owner permissions on "B" I don't know if you would like that, its very dependent on the enviroment. If more than one team uses the same SQL Server box it may not be a good idea!

HTH


* Noel
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