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.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Join tables of Different databases

Author  Topic 

Hari.b83
Starting Member

4 Posts

Posted - 2007-08-20 : 05:05:22
Hi Ppl,

I am running a query with database defaulting to 'test' and trying to do an equi join with northwind database table 'ProjectHR' ( i created it).

select g.emp_id,p.proj_id,[g.name] from Gilma g,northwind.ProjectHR p where p.emp_id = g.emp_id.

But it does not work. Not sure why?

cheers,

Hari

nr
SQLTeam MVY

12543 Posts

Posted - 2007-08-20 : 05:10:44
northwind.dbo.ProjectHR
or
northwind..ProjectHR

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

under2811
Constraint Violating Yak Guru

366 Posts

Posted - 2007-08-20 : 05:12:45
Hi,

select g.emp_id,p.proj_id,g.name
from [test].[dbo].[Gilma] g,[northwind].[dbo].ProjectHR p
where p.emp_id = g.emp_id
Go to Top of Page

Hari.b83
Starting Member

4 Posts

Posted - 2007-08-20 : 05:23:29
Hi All,

Thanks for your immediate response. Although this is what i am getting when i run the query as you said:

Msg 208, Level 16, State 1, Line 1
Invalid object name 'northwind.dbo.ProjectHR'.

ProjectHR exists. I confirm.

Regards!
Go to Top of Page

Hari.b83
Starting Member

4 Posts

Posted - 2007-08-20 : 05:38:39
Sorry but is this because i'm using the Express Edition???
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-08-20 : 08:39:37
quote:
ProjectHR exists. I confirm.

in NorthWind database ?


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-08-20 : 08:50:19
What happened to the ANSI join style?

select g.emp_id, p.proj_id,[g.name]
from Gilma as g
inner join northwind.dbo.ProjectHR as p on p.emp_id = g.emp_id



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page
   

- Advertisement -