Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Could not find server 'DB name' in sys.servers (not dbo issue)

Today I encountered a problem saying that my "server" could not be find in sys.servers. The error was:

Could not find server 'DB name' in sys.servers

It's not an issue of using a prefix in certain cases but not others as with the "dbo" issues that others were having.

like image 842
Ynhockey Avatar asked Apr 16 '14 13:04

Ynhockey


2 Answers

If you are trying to access your database from a different server and you get this message then add a linked server. (sp_addlinkedserver)

if you are trying to access your database on the same server then check if it is registered. select * from sys.sysservers

like image 90
Adam Riley Avatar answered Oct 31 '22 00:10

Adam Riley


There are a lot of situations where you can get this error, and many of them are covered on StackOverflow. However, one case which might especially be encountered on shared servers is simply that the database name has a period (dot) in it. For example, if its name is mysite.com_DB. This will automatically cause the problem.

The solution, if you can't rename the database, is to encapsulate the DB name in square brackets, so for example:

mysite.com_DB.Table_name

Will turn into:

[mysite.com_DB].Table_name
like image 32
Ynhockey Avatar answered Oct 31 '22 00:10

Ynhockey