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 2012 Forums
 Transact-SQL (2012)
 Could not find server 'SQL-Studentdb' in sys.ser

Author  Topic 

SQLBoy14
Yak Posting Veteran

70 Posts

Posted - 2014-09-21 : 19:00:31
Hello,

I am trying to find out what the issue that is causing below error:

Msg 7202, Level 11, State 2, Line 1
Could not find server 'SQL-Studentsrv' in sys.servers. Verify that the correct server name was specified. If necessary, execute the stored procedure sp_addlinkedserver to add the server to sys.servers.

From my query:
SELECT *
FROM [SQL-Studentsrv].[Studentdb].[Studenttbl]

If I removed the [SQL-Studentsrv] it worked but when I tried to have completed path, then got the above error.


Anyone knows why?

SQLBoy

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2014-09-21 : 19:32:17
SQL-Studentsrv isn't setup as a linked server. Are you intending to use a linked server? Or is SQL-Studentsrv the local server?

You also need to change your code to use the 4-part naming convention if you are going to use a linked server. You are missing the schema name:
LinkedServerName.DatabaseName.SchemaName.ObjectName

Tara Kizer
SQL Server MVP since 2007
http://weblogs.sqlteam.com/tarad/
Go to Top of Page

SQLBoy14
Yak Posting Veteran

70 Posts

Posted - 2014-09-21 : 19:41:12
Hi Tkizer, SQL-Studentsrv is the local server.

SQLBoy
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2014-09-22 : 12:52:24
quote:
Originally posted by SQLBoy14

Hi Tkizer, SQL-Studentsrv is the local server.

SQLBoy



Then don't specify it in your query.

Tara Kizer
SQL Server MVP since 2007
http://weblogs.sqlteam.com/tarad/
Go to Top of Page

Bustaz Kool
Master Smack Fu Yak Hacker

1834 Posts

Posted - 2014-09-22 : 19:18:30
Patient: It hurts when I do this!
Doctor: Then don't do this!!

Seriously though, what do you get when you run this:
select *
from sys.servers




Too often we enjoy the comfort of opinion without the discomfort of thought. - John F. Kennedy
Go to Top of Page

gbritton
Master Smack Fu Yak Hacker

2780 Posts

Posted - 2014-09-23 : 15:48:38
isn't [SQL-Studentsrv].[Studentdb].[Studenttbl]

a three-part name? According to http://msdn.microsoft.com/en-CA/library/ms177563.aspx

that should be database . schema . object

I can't quite see how sql server is looking at the first token as a linked server name.
Go to Top of Page

SQLBoy14
Yak Posting Veteran

70 Posts

Posted - 2014-09-23 : 22:51:28
Hi Bustaz Kool, thank you for that query, I am able to see the actual name of the server, data source. I can see some of the servers that my school is having. That makes easier now. Thanks again.

SQLBoy
Go to Top of Page

Bustaz Kool
Master Smack Fu Yak Hacker

1834 Posts

Posted - 2014-09-24 : 12:14:30
gbritton,
Brilliant !!! And, boy, do I feel like an idiot. I just couldn't see the forest because of all those damn trees...




Too often we enjoy the comfort of opinion without the discomfort of thought. - John F. Kennedy
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2014-09-24 : 12:25:46
I just assumed that was a typo in this post since a 3-part name wouldn't have given that error. Only a 4-part name would mention a sys.servers as far as I know.

Tara Kizer
SQL Server MVP since 2007
http://weblogs.sqlteam.com/tarad/
Go to Top of Page
   

- Advertisement -