Link to home
Start Free TrialLog in
Avatar of muntasirrahman
muntasirrahman

asked on

You cannot create a Local sql Server as a Link server

Dear ALL,

                I have inherited a server which shows following massage when I use 4 part table name.

My query is:

select
         sum(amount) AS Event
 from MylocalServer.RA_P07.dbo.P07_C60A21_stage


Server: Msg 7202, Level 11, State 2, Line 1

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

 
When I use sp_addlinkedserver from Enterprise Manager it shows following Error:
    You cannot create a Local sql Server as a Link server

 And on sysservers table I have found no entry for MylocalServer

 Can any one Help me on that

 Thanks In Advance

Muntasir

Avatar of rafrancisco
rafrancisco

When referencing objects on the local server, you don't need to specify the server name.  You only use the 4-part table name if you are referencing objects from other servers.  Given this, you query should look like this:

select
         sum(amount) AS Event
 from RA_P07.dbo.P07_C60A21_stage
Avatar of muntasirrahman

ASKER

i know, but  it does not create problem with my other server
Execute this SELECT statement and tell me the values returned:

select host_name(), @@SERVERNAME
Dear rafranscio

@@servername shows 'NULL' value
ASKER CERTIFIED SOLUTION
Avatar of rafrancisco
rafrancisco

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Once @@SERVERNAME contains a value, try your query again.