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 1Could 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.ObjectNameTara KizerSQL Server MVP since 2007http://weblogs.sqlteam.com/tarad/ |
|
|
SQLBoy14
Yak Posting Veteran
70 Posts |
Posted - 2014-09-21 : 19:41:12
|
Hi Tkizer, SQL-Studentsrv is the local server.SQLBoy |
|
|
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 KizerSQL Server MVP since 2007http://weblogs.sqlteam.com/tarad/ |
|
|
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 |
|
|
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.aspxthat should be database . schema . objectI can't quite see how sql server is looking at the first token as a linked server name. |
|
|
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 |
|
|
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 |
|
|
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 KizerSQL Server MVP since 2007http://weblogs.sqlteam.com/tarad/ |
|
|
|