Assuming you are running this from the TEST1 database, this should do
the trick:
SELECT A.F1, A.F2, A.F3, B.F1, B.F2, B.F3 FROM TableA A INNER JOIN
TEST2.dbo.TableB B ON A.F4 = TEST2.dbo.TableB.F4
You need to put the table owner in the 3 part name. I have used 'dbo'.
Carol.
-----Original Message-----
From: Indra Timilsina
[mailto:mssqldba-ezmlmshield-x52526195.[Email address protected]
Sent: 24 February 2006 16:08
To: LazyDBA Discussion
Subject: creating query from two different database.
Hi there,
I am looking for information on how to create query with tables from two
different databases which are in same server
Like table A is in database TEST1
And table B is in database TEST2
I need to select A.F1, A.F2, A.F3 AND B.F1, B.F2, B.F3 WHERE A.F4=B.F4
Thanks.
---------------------------------------------------------------------
TO REPLY TO EVERBODY , PLEASE CLICK REPLY-ALL, NOT JUST REPLY Website :
http://www.LazyDBA.com To unsubscribe:
http://www.lazydba.com/unsubscribe.html
This email and any files transmitted within it are private and confidential.
If you are not the intended recipient, this email and any attachments within it have been transmitted to you in error.
You are prohibited from using, copying, distributing or otherwise using the information contained within this email.
Nothing in this email message amounts to a contractual or legal commitment on the part of Optilan unless confirmed by a communication signed on behalf of the company.
Any email cannot be guaranteed to be secure, error free or free from viruses. Although every possible care is taken by Optilan, Optilan does not accept any liability whatsoever for any loss or damage which may be caused as a result of the transmission of this message by email.
MS Sql Server LazyDBA home page