views:

26

answers:

2

Hi, I have two databases at the same server 192.168.1.100 DB1 and DB2

When I'm trying to execute :

select h.code,eh.Defaultname From hotels h JOIN [192.168.1.100].[dbo].[DB2].Hotels eh ON h.code = eh.code

I get

Could not find server '192.168.1.100' in sysservers. Execute sp_addlinkedserver to add the server to sysservers.

I don't understand :/

I'm using ms sql server 2005 and this query is fired when I'm at DB1.

What's the reason of this , and how to fix it ? :/

+3  A: 

Since the databases are on the same SQL Server instance, you don't need to use a linked server, so don't specify the IP, just the other database's name.

select h.code,eh.Defaultname 
From hotels h 
JOIN [DB2].dbo.Hotels eh ON h.code = eh.code
Blorgbeard
tkank you very much
+1  A: 

JOIN [DB2].[dbo].[Hotels] AS eh

Damir Sudarevic