Could not find server 'server name' in sys.servers. SQL Server 2014
I figured out the issue. The linked server was created correctly. However, after the server was upgraded and switched the server name in sys.servers
still had the old server name.
I had to drop the old server name and add the new server name to sys.servers
on the new server
sp_dropserver 'Server_A'
GO
sp_addserver 'Server',local
GO
Could not find server in sys.servers. Verify that the correct server name was specified
If you are getting that message then for sure that server is not registered. to verify you can check
select * from sys.sysservers where srvname = 'BIZTALKSERVERSE'
To register you can check the below MSDN links
https://msdn.microsoft.com/en-us/library/ms188717.aspx
https://msdn.microsoft.com/en-us/library/ms188231.aspx
Could not find server 'DB name' in sys.servers (not dbo issue)
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
DataAdapter.Fill gives error Could not find server 'System' in sys.servers.
This is wrong:
SqlDataAdapter sqlDA = new SqlDataAdapter(cmd2.ToString(), conx.ConnectionString);
cmd2 is a SqlConnection, which doesn't have a ToString of its own, so it uses the default one from object which is simply the type of the object. This means your "SQL" as the data adapter saw it, ends up being "System.Data.SqlClient.SqlConnection"
and your sqlserver thinks you're calling a stored procedure on another server called "System" (in a database called Data, in a schema called SqlClient, for a proc called SqlConnection)
Just do this:
var dt = new DataTable();
using var da = new SqlDataAdapter("SELECT * FROM Ordenes_Servicios", conx);
da.Fill(dt);
Throw all that other code away; it's all extraneous. You only need these 3 lines. A dataadapter knows how to open a connection itself
Could not find server 'dbo' in sys.servers
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.
Linked Server Query works, but OPENQUERY of same produces error Could not find server 'SERVER' in sys.servers
Because when you use OPENQUERY you send the query you want to run on the remote server. The error is being thrown by the remote server. Take out the linked server name in the query. Something along these lines.
SELECT [Col1]
FROM OPENQUERY([LINKEDSERVER],
'SELECT tbl.[Col1]
,tbl.[CoL2]
FROM [CATALOG].[SCHEMA].[TABLENAME] tbl'
) As Whatever
How to get passed could not find server for a linked server select within an if exists?
I like to setup synonyms for tables that exist in databases that are different between DEV/PROD. Example: in DEV I want to use the table DatabaseDEV.dbo.UserAccount' and during PROD I want to use the table
DatabasePROD.dbo.UserAccount'.
What I do is setup a SYNONYM like this in DEV:
CREATE SYNONYM dbo.UserAccount FOR DatabaseDEV.dbo.UserAccount
And setup a SYNONYM like this in PROD:
CREATE SYNONYM dbo.UserAccount FOR DatabasePROD.dbo.UserAccount
Then in my code I reference SELECT * FROM dbo.UserAccount
. As the SPROC/VIEW is moved from DEV --> PROD it changes from one database to the other. This also works if you have a linked server.
Could not find server 'dbo' in sys.servers
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.
Related Topics
Referencing a Composite Primary Key
How to Get a Real Time Within Postgresql Transaction
Oracle SQL Order by in Subquery Problems!
Maximum Length of an SQL Query
Resources for Database Sharding and Partitioning
Oracle SQL Group by "Not a Group by Expression" Help
Oracle - Clone Table - Structure, Data Constraints and All
Creating a Table from a Query Using a Different Tablespace (Oracle Sql)
How to Send a Query Result in CSV Format
How to Get Referenced Values from Another Table
Rails 3 Sum Product of Two Fields
Arel Causing Infinite Loop on Aggregation
How to Find Out If an Oracle Database Is Set to Autocommit
Generate Series of Week Intervals for Given Month
Select 10 Rows Per Day with Order
Selecting Multiple Rows by Id, Is There a Faster Way Than Where In
How to Use a Case Statement in Scalar Valued Function in Sql