Could not find server 'dbo' in sys.servers
Asked Answered
S

5

13

I have a lot of services which query the database. All of them work fine but one service calling a stored procedure gives me following error:

Could not find server 'dbo' 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.

I have not idea why all the other stored procedures work fine and this one not...

By the way, I use SubSonic as data access layer.

Shaeshaef answered 20/3, 2009 at 10:46 Comment(0)
T
13

It sounds like there is an extra "." (or two) in the mapping - i.e. it is trying to find server.database.schema.object. Check your mapping for stray dots / dubious entries.

Touchandgo answered 20/3, 2009 at 10:52 Comment(2)
If you have table names that contain periods, you'll also want to check that the name is enclosed in brackets, e.g., dbo.[SubSchema.Table] instead of dbo.SubSchema.Table.Oneupmanship
Thx, apparently some underscores were replaced by dots... no clue as why this happened. Thx.Shaeshaef
S
15

Please run select name from sys.servers from the server which you mentioned as default server in configuration file.

Here in name column values should match with your server names used in the report query.

e.g serverXXX.databasename.schema.tablename

serverXXX should be there in the result of select name from sys.servers otherwise it gives error as got.

Schizopod answered 26/4, 2012 at 10:19 Comment(1)
It should be noted that evidently the name IS case sensitive. I was using a lower case version of a server name and intellisence picked up everything fine, but when time came for execution, I got the original poster's error. Then I used "select * from sys.servers" and noticed the server name was all caps, so I switched to that, viola! It worked! +1 for setting me on the right path.Metopic
T
13

It sounds like there is an extra "." (or two) in the mapping - i.e. it is trying to find server.database.schema.object. Check your mapping for stray dots / dubious entries.

Touchandgo answered 20/3, 2009 at 10:52 Comment(2)
If you have table names that contain periods, you'll also want to check that the name is enclosed in brackets, e.g., dbo.[SubSchema.Table] instead of dbo.SubSchema.Table.Oneupmanship
Thx, apparently some underscores were replaced by dots... no clue as why this happened. Thx.Shaeshaef
C
4

Also make sure that the server name matches what you think it is. If you rename the host that SQL Server is running on, you need to rename the SQL Server, too.

http://www.techrepublic.com/blog/datacenter/changing-the-name-of-your-sql-server/192

Coatbridge answered 31/5, 2011 at 18:58 Comment(0)
S
1

I had another issue with the same exception so I'll post here if someone stumble upon it:

Be careful if you specify the server name in synonyms. I had a different server name on my staging machine and production and it caused the same 'cannot find server'-error.

(Guess you shouldn't use synonyms that much anyway but it's useful in some migration scenarios)

Shaikh answered 10/11, 2010 at 14:47 Comment(0)
L
0

In my case i was facing same issue with following ,

  SqlCommand command = new SqlCommand("uspx_GetTemplate", connection);

but after adding square bracket to stored procedure name it get solved.

SqlCommand command = new SqlCommand("[uspx_GetTemplate]", connection);
Loralyn answered 4/9, 2020 at 13:12 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.