Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Hi,Need to know the syntax for accessing all coluumns on different tables which are on separate databases???? Any idea, pls help!!!
Seventhnight
Master Smack Fu Yak Hacker
2878 Posts
Posted - 2004-06-01 : 16:19:04
SelectA.*, B.*From db1.dbo.tableA as AInner Join db2.dbo.tableB as Bon A.id = B.id
surefooted
Posting Yak Master
188 Posts
Posted - 2004-06-01 : 16:21:40
With no join criteria??
select a.*, b.*from [database]..[tablename] a, [database]..[tablename]b
With join criteria...
select a.*, b.*from [database]..[tablename] a join [database]..[tablename]bon a.[column] = b.[column]
-JonJust a starting member.
bb_anand
Starting Member
13 Posts
Posted - 2004-06-01 : 16:22:18
Can we use full Outer Join in place of inner join?
bb_anand
Starting Member
13 Posts
Posted - 2004-06-01 : 16:25:27
what in case if the databases are lying on different servers (hardware)...should I need to define the path of the server too???
bb_anand
Starting Member
13 Posts
Posted - 2004-06-01 : 16:25:31
what in case if the databases are lying on different servers (hardware)...should I need to define the path of the server too???
surefooted
Posting Yak Master
188 Posts
Posted - 2004-06-01 : 16:29:00
You can use any join you like.To access the tables from different machines, use a fully qualified name [Servername].[Database].[Owner].[tablename] where Servername is a linked server. You can also use open query. OPENQUERY ( linked_server , 'query' )-JonJust a starting member.