• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 247
  • Last Modified:

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

0
muntasirrahman
Asked:
muntasirrahman
  • 4
  • 2
1 Solution
 
rafranciscoCommented:
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
0
 
muntasirrahmanAuthor Commented:
i know, but  it does not create problem with my other server
0
 
rafranciscoCommented:
Execute this SELECT statement and tell me the values returned:

select host_name(), @@SERVERNAME
0
Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

 
muntasirrahmanAuthor Commented:
Dear rafranscio

@@servername shows 'NULL' value
0
 
rafranciscoCommented:
Try this and see if @@SERVERNAME gets a value:

EXEC sp_addserver 'MylocalServer', 'local'
0
 
rafranciscoCommented:
Once @@SERVERNAME contains a value, try your query again.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now