I am trying to create a linked server in SQL Server:
--Create the link to server "uranium"
EXEC master.dbo.sp_addlinkedserver
#server = N'uranium',
#srvproduct=N'',
#provider=N'SQLNCLI'
--Add the catch-all login with SQL Server authentication
EXEC master.dbo.sp_addlinkedsrvlogin
#rmtsrvname=N'uranium',
#useself=N'False',
#locallogin=NULL,
#rmtuser=N'BatteryStaple',
#rmtpassword='Horsecorrect'
And it creates fine. But any attempt to query the linked server, e.g.:
SELECT * FROM uranium.Periodic.dbo.Users
results in
Msg 18456, Level 14, State 1, Line 1
Login failed for user 'BatteryStaple'.
Except i know the credentials are correct:
Login: BatteryStaple
Password: Horsecorrect
because i can login when i connect directly using SQL Server Management Studio, or any other technology that is able to connect to a database.
Bonus Reading
Login Failed for linked server (he forgot to call sp_addlinkedsrvlogin)
Why am I getting a “login failed” when creating this linked server? (he's trying to use integrated authentication)
MSDN Blogs: SQL Linked Server Query failed with “Login failed for user …” (he's trying to make integrated authentication work)
Note: New SQL Server 2014 install. Every existing SQL 2000, 2005, 2008, 2008 R2 can communicate to their uranium linked server. I'm certain it is related to Microsoft's frustrating broken by default policy.
The issue is that the SQL Server Management Studio interface creates the linked server using the OLEDB Provider:
This is equivalent to the original T-SQL:
--Create the link to server "uranium"
EXEC master.dbo.sp_addlinkedserver
#server = N'uranium',
#srvproduct=N'', #provider=N'SQLNCLI'
The fix is to create the linked server as SQL Server:
--Create the link to SQL Server "uranium"
EXEC master.dbo.sp_addlinkedserver
#server = N'uranium',
#srvproduct=N'SQL Server'
Shouldn't matter. Probably a regression in Microsoft SQL Server 2014 12.0.4213.0. Might be fixed in a service pack - if there is one.
But there it is; solved.
Old post, but might be useful still. In my case it was that only Windows Authentication was set. Setting authentication for both Windows and SQL Server on the linked server fixed it.
The issue for me was this: Since I was trying to connect to instance via servername\instancename - ALL my instances were running on port 1433 so the "Add Linked Server" was actually connecting to the default instance - and the login was failing.
Go to SQL Configuration Manager
Click on Protocols for [instancename]
Open TCP/IP properties and be sure it's enabled AND flip to the "IP Addresses" Tab and change the port on ALL IPs that you are using for your linked server IP is (a) active and (b) using a unique port - like 14333 (this was important as my VPN IP was not "active".
You may have to do this for both 32 and 64 if your machine is running both
DONT FORGET TO STOP and START THE INSTANCE
This is the fix
Related
Having a really odd issue that I am banging my head against.
SQL Server 2008 running on Windows Server R2 setting up a linked server using a 3rd party ODBC driver.
Created the system DSN for the third party connection on the sql server, created the linked server using:
EXEC master.dbo.sp_addlinkedserver #server = N'NS_PROD', #srvproduct=N'NS', #provider=N'MSDASQL', #datasrc=N'NS_PROD', #location=N'NS', #provstr=N'SDSN=xxx;HST=xxx;PRT=xxx;UID=xxx;PWD=xxx', #catalog=N'Administrator'
EXEC master.dbo.sp_addlinkedsrvlogin #rmtsrvname=N'NS_PROD',#useself=N'False',#locallogin=NULL,#rmtuser=N'xxx',#rmtpassword='xxx'
Logged in to local desktop, fired up SSMS, tested linked server successfully.
After logging out of the desktop of the SQL Server, within 10 minutes, linked server starts timing out from SSMS.
Logging back into the SQL Server desktop restores the connection to the linked server.
Is it losing the ability to access the system DSN if there is no user desktop? This make no sense to me.
Any help is appreciated.
Network firewall caused the issue.
I have recently installed SQL Server 2014 Express and need to create a linked server. I have tried this in SQL Server Management Studio (from the object explorer - server objects - linked servers - add linked server).
When connecting to the server directly through Server type "SQL server" or by specifying the connection attributes in "Other data source" then Microsoft OLE DB Provider for SQL Server and filling in the additional details I receive the following error.
The linked server has been created but failed a connection test. SQL
Server native client 11.0 does not support connections to SQL Server
2000 or earlier versions.
I need to be able to create a joined query between two databases on different servers, what is the best way of achieving this ? The database I need to connect to is Version 8 (SQL Server 2000), very old. I have read it might be possible to achieve through transact SQL but not sure what steps to take.
It is possible to create a linked server but it cannot be done through the GUI. As a workaround you can create a DSN to use in transact SQL to link the servers.
For full instructions visit http://sqlwithmanoj.com/2012/12/10/sql-server-2012-does-not-support-linked-server-to-sql-server-2000-workaround/
=> WORKAROUND / FIX:
Now as a workaround to make this Linked Server work we have an option to use the ODBC Data Source which will connect to our remote server.
There are 2 approaches:
1. Either we create an ODBC Data Source (DSN) and use it in our Linked Server
2. Or, use the Data Source (DSN) connection string directly in the Linker Server Provider
–> Using appraoch #1:
Create an ODBC Data Source:
– Open Control Panel, go to Administrative Tools, then “Data Sources (ODBC)”.
– On “ODBC Data Source Administrator” window go to “System DSN” Tab.
– Here click on Add to create a new DSN.
– Choose “SQL Server” and click Finish.
– On the new window, give a proper name for the Source DSN (like: NorthWind2000DSN), we will use this name while creating our Linked Server. Provide the Server name which is on SQL Server 2000, here “NorthWind”. Click Next.
– Choose the Authentication Type, either Windows or SQL Server auth. Click Next.
– Change the default database, not necessary. Click Next.
– Click Finish. You will see a new DSN created under System DSN tab.
Now, create Linked Server and provide this DSN in the #datasrc param and provide the #provider param “MSDASQL”.
You can use the below query to create the same:
USE master
GO
-- Drop Existing LinkedServer [NorthWind2000]:
EXEC sp_dropserver #server=N'NorthWind2000', #droplogins='droplogins'
GO
-- Re-create LinkedServer [NorthWind2000] by using the ODBC connection:
EXEC sp_addlinkedserver #server = N'NorthWind2000',
#srvproduct=N'MSDASQL',
#provider=N'MSDASQL',
#datasrc = N'NorthWind2000DSN',
#location=N'System';
EXEC sp_addlinkedsrvlogin #rmtsrvname=N'NorthWind2000',
#useself=N'True',
#locallogin=NULL,
#rmtuser=NULL,
#rmtpassword=NULL
GO
–> Using appraoch #2:
We can also directly put the DSN connection String in the Provider String #provstr param.
Let’s check it below:
USE master
GO
-- Drop Existing LinkedServer [NorthWind2000]:
EXEC sp_dropserver #server=N'NorthWind2000', #droplogins='droplogins'
GO
-- Re-create LinkedServer [NorthWind2000] by using the ODBC connection:
EXEC sp_addlinkedserver #server = N'NorthWind2000',
#srvproduct=N'',
#provider=N'MSDASQL',
#provstr=N'DRIVER={SQLServer};SERVER=NorthWind;Trusted_Connection=yes;'
EXEC sp_addlinkedsrvlogin #rmtsrvname=N'NorthWind2000',
#useself=N'True',
#locallogin=NULL,
#rmtuser=NULL,
#rmtpassword=NULL
GO
I created an ODBC database on my local machine with driver SQL server Native client 10.0, which connects to a remote server, see
.
I am working on a project about customized ODBC to an inhouse database and want to Test how I can connect to a data source using ODBC.
The question is how can I connect to the local ODBC using sql server studio manager? I tried
but it returns an error:
A network-related or instance-specific error occurred while
establishing a connection to SQL Server. The server was not found or
was not accessible. Verify that the instance name is correct and that
SQL Server is configured to allow remote connections. (provider: Named
Pipes Provider, error: 40 - Could not open a connection to SQL Server)
Any idea?
Connect to your local server through SSMS then create a linked server to the ODBC connection.
Echoing #Brian Boyd...
It is possible to create an ODBC connection to a SQL server running locally.
If you start SSMS and point it to a local database engine the Server Name should be Computer_Name\SQLEXPRESS with Authentication set to Windows Auth (ie the logged-in user: you). Computer_Name is found in the System window (Windows Key + Break) and is not localhost, 127.0.0.1, etc.
So, to set up an ODBC connection by running %windir%\syswow64\odbcad32.exe
In the System DSN tab, click [Add...]
Select SQL Server in the drivers list, click [Finish]
Now add a Name and Description but most importantly set the Server to be Computer_Name\SQLEXPRESS (whatever was shown in SSMS)
Click [Next] and leave the authentication set to Windows NT
Click [Next] and tick the default database tickbox to reveal a list of databases locally (if yours is listed here the ODBC settings have already worked)
Click [Next], [Finish] then [Test Data Source...] then all should be well
To connect to a remote server you don't need a DSN. You can enter the server name in the Server name field of SQL Server Management Studio and select Windows authentication or Database authentication.
It is not possible to connect SSMS to an ODBC data source. The only way is to create a linked server in your local SQL server as #Brian Boyd described.
Instructions are:
https://community.sagecrm.com/partner_community/b/hints_tips_and_tricks/archive/2010/05/10/connecting-to-a-sage-mas-erp-90-database-as-a-linked-server-within-ms-sql-server-2008.aspx
... and sp_AddLinkedServer documentation from MS HERE
… and with search = “sp_addlinkedserver for SOTAMAS90“, even an example from 2005
https://blog.coryfoy.com/2005/06/lets-go-crazy-accessing-timberline-pervasive-data-from-a-sql-linked-server/
Let’s see what turn says …. And think I will / would get the same error adding a linked server through UI that I get TSQL
Based on above, I tried …
EXEC sp_addlinkedserver
#server = 'TimberlineTest',
#provider = 'SOTAMAS90', -- Original command #provider = MSDASQL',
#srvproduct = '', --- MAS 90 4.0 ODBC Driver Original is #srvproduct='Timberline Data',
#datasrc = 'DataTest'
I need to connect to a SQL server 2000 Database from SQL server 2008.
SQL server 2000 properties:
ServerName:WinxpV1\SQL2k
UserName:Raymond
password:xxxxx
Computer Ip address:192.168.100.124
And I'm trying to connect to it using following method:
File-->Connect to:
ServerName:WinxpV1\SQL2k
Authentication:SQL server Authentication
Login:Raymond
Password:xxxxx
TCP/IP is enable in "SQL server utility" in SQL2000. but I can't connect to it.
Can you use linked servers?
Exec master.dbo.sp_addlinkedserver
#server=N'WinxpV1\SQL2k'
, #srvproduct=N'SQL Server' --I'm guessing here
, #provider=N'SQLNCLI'
, #provstr=(Your connection string here)
You can use sp_addlinkedsrvlogin if you can't pass your credentials in the connection string. Here's a good site for connection strings too: http://www.connectionstrings.com/ (I have no affiliation with this site; I have found it helpful on many occasions.)
I have two SQL Servers which have been linked using sp_addlinkedserver 'ServerB\Instance' from ServerA and sp_addlinkedserver 'ServerA\Instance' from ServerB.
If I execute the following query from ServerA then everything is okay:
SELECT *
FROM [ServerB\Instance].Database.dbo.Table
If I execute the following query from ServerB an error occurs:
SELECT *
FROM [ServerA\Instance].Database.dbo.Table
Error:
Msg 18456, Level 14, State 1, Line 1
Login failed for user 'NT
AUTHORITY\ANONYMOUS LOGON'.
The service accounts that SQL Server runs under on ServerA and ServerB have been given elevated permissions on both servers in an attempt to solve the issue but no success.
I have done research but want to avoid a convoluted process when communication one way is okay.
I have solved this by following the process:
Deleted both linked servers.
Executed sp_addlinkedserver for ServerA from ServerA RDP (SSMS) and for ServerB from ServerB RDP (SSMS).
Previously I had executed sp_addlinkedserver for both servers from the one server RDP (SSMS) session only. Executing from each server has solved the problem. If someone can add comments as to why this is then I will be very grateful.
In SQL Management Studio, view the properties for the linked server from Server B to Server A. There's a security "tab" that you can view from there. That will tell you the security context the connection from B to A is using. The error you are getting normally occurs when you don't have a valid security context set for the linked server.
The reason that it can work from A to B and not B to A is that you need to set up the linked server correctly on each side. Just doing it for one is not going to work to go both ways.
You have to map your local user to a remote user on the other server.
Do can do this by calling sp_addremotelogin() as explained here: http://msdn.microsoft.com/en-us/library/ms186338.aspx
To work around this problem, use one of the following methods:
Map the clients on server A to a standard security login on server B, by using either the sp_addlinkedsrvlogin stored procedure or the Security tab of the Linked Server Properties dialog box in Enterprise Manager.
If you are running the distributed query on an instance of SQL Server that is running on a Microsoft Windows 2000-based computer, configure SQL Server to listen for client requests by using the Named Pipes Server network library, instead of using the TCP/IP Server network library or the Multiprotocol Server network library. To configure the Server network libraries for SQL Server, use the Server Network Utility.
Take a look at:
http://support.microsoft.com/kb/238477