Friday, March 30, 2012

Multi Table Query

Does anyone know how to create a query using tables from different sql server database's? looking for the simplest solution.

I have two databases in sql server. Both are in the same "server registration"
How do i reference a table in another database?

Do i do something like this?

SELECT Database1.Table1.Fields, Database2.Table1.Fields
FROM Database1.table1.PKField INNER JOIN Database2.table1.FKField;You may try this

SELECT Database1.dbo.Table1.Fields,
Database2.dbo.Table1.Fields FROM
Database1.dbo.table1.PKField INNER JOIN
Database2.dbo.table1.FKField|||you might also want to look at the OPENQUERY funtion. buddu's suggestion will work but you can generate a buch of unwanted I/O if the table on the remote server is big.|||You only need to do the full naming convension in the FROM clause

SELECT x.column1,
x.column2,
y.column1,
y.column3
FROM database1.dbo.tableX x
JOIN database2.dbo.tabley y
ON x.pk = y.pk|||can anyone help me please...
what query/syntax could i use for retrieving fields from various tables in Access for my one FORM.?
Ive tried using every possible codes but then it didn't work out.
SHould i declare diffrent recordsets for accesing this?

No comments:

Post a Comment