Linked Server SQL Server 2014 to SQL Server Version 8 - sql-server

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

Related

SQL Server linked server configuration

I want to create a connection from my local SQL Server to the production enviroment SQL Server so that I can perform certain tasks.
is that possible ?
Yes it is possible. What you need to do is to setup a linked server environment. Assuming the prod environment you are referring to uses uses SQL Server, you can set it up as follows:
USE [master]
GO
EXEC master.dbo.sp_addlinkedserver
#server = N'YourServerName\InstanceNameIfAny',
#srvproduct=N'SQL Server' ;
GO
To test the linked server you just setup, run this:
SELECT name FROM [YourServerName\InstanceNameIfAny].master.sys.databases
This will return the names of the databases on the linked server.
If you are more comfortable with GUI, here is what you can do instead:
In SSMS, Expand Server Objects -> Linked Servers -> (Right click on the Linked Server Folder and select “New Linked Server”)

Login failed when querying linked server

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

SQL Server 2012 querying Access 2007 data using OPENROWSET error

I would like to query data in Management Studio from a Microsoft Access 2007 database located on the same machine as my SQL Server 2012 instance. I do NOT want to use a linked server to do this as different Access databases can be chosen by the user. I am following the directions found on technet and other sources I have read said to use OPENROWSET as the proper way to do what I want, but when I execute this in Management Studio...
SELECT *
FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0',
'C:\Users\oliver.klosoff\Desktop\New folder\41000-13-0085 Consolidated Killers LLC.mdb';
'admin';'',tblTtlHrsFringes);
...I get the error below:
Msg 7302, Level 16, State 1, Line 1
Cannot create an instance of OLE DB provider "Microsoft.Jet.OLEDB.4.0" for linked server "(null)".
The database does not have a password set for the admin user, and the admin user has permissions to read this table. Access 2007 32bit is installed on the machine, which is 64 bit, as well as the SQL Server instance. I believe that SQL Server can access the database file because when I get 1 when I execute this:
DECLARE #out INT
EXEC master.dbo.xp_fileexist 'C:\Users\oliver.klosoff\Desktop\New folder\41000-13-0085 Consolidated Killers LLC.mdb', #out OUTPUT
SELECT #out`
Is there a way to do what I am trying to accomplish?
Finally, after several unsuccessful attempts to have SQL Server "talk to" an Access database – either as a "Linked Server" in SSMS or via OPENROWSET() in T-SQL – I found this blog post that offered the following three (3) suggestions.
Tweak #1: OLE DB Provider settings
The OLE DB Provider for ACE (or Jet) must have the "Dynamic parameter" and "Allow inprocess" options enabled. In SSMS, open the
Server Objects > Linked Servers >Providers
branch, right-click "Microsoft.ACE.OLEDB.12.0" (or "Microsoft.Jet.OLEDB.4.0"), choose "Properties", and ensure that those options are selected:
Tweak #2: Temp folder permissions
This is the one that was stumping me.
Apparently SQL Server needs to write information into a temporary file while running an OLE DB query against an Access database. Because SQL Server is running as a service it uses the %TEMP% folder of the account under which the service is running.
If the SQL Server service is running under the built-in "Network Service" account then the temp folder is
%SystemRoot%\ServiceProfiles\NetworkService\AppData\Local\Temp
and if it is running under the built-in "Local Service" account then the temp folder is
%SystemRoot%\ServiceProfiles\LocalService\AppData\Local\Temp
My problem was that SSMS was running under my account (not NETWORK SERVICE) so I only had Read access to the Temp folder
Once I granted myself Modify permissions on that folder
and enabled OPENROWSET queries as documented in another question here, namely ...
EXEC sp_configure 'show advanced options', 1
RECONFIGURE
GO
EXEC sp_configure 'ad hoc distributed queries', 1
RECONFIGURE
GO
... my query worked fine:
Tweak #3: memory_to_reserve
Although I didn't need to use it in my case, the aforementioned blog also claims that adjusting the "-g memory_to_reserve" startup parameter for the SQL Server service can also help avoid similar errors. To do that:
launch SQL Server Configuration Manager
right-click the SQL Server service ("SQL Server Services" tab) and choose "Properties"
on the "Advanced" tab, prepend -g512; to the "Startup Parameters" setting
restart the SQL Server service
For more details on the "memory_to_reserve" setting see the MSDN article here.
This should work
EXEC sp_configure 'show advanced options', 1;
GO
RECONFIGURE;
GO
EXEC sp_configure 'Ad Hoc Distributed Queries', 1;
GO
RECONFIGURE;
GO
USE [DatabaseName]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SELECT * FROM OPENDATASOURCE('Microsoft.ACE.OLEDB.12.0','Data Source="C:\Employees.accdb"')...tblEMPS;
Assuming you have the 'Northwind' sample installed (and in folder mentioned below), will the following run?
SELECT CustomerID, CompanyName
FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0',
'C:\Program Files\Microsoft Office\OFFICE11\SAMPLES\Northwind.mdb';
'admin';'',Customers);
GO
Unfortunately I have not reinstalled SQL Server since my last reimage
Microsoft.Jet.OLEDB.4.0 may not work now(in 2018). Need to download AccessDatabaseEngine_X64.exe or AccessDatabaseEngine.exe to SQL server and intall it. Then use Microsoft.ACE.OLEDB.12.0.

SQL Server 2000 - Linked Server

For our application, we using SQL Server 2000 & MySQL. I want to update the MySQL database if any modifications in SQL Server 2000. For this, I have created the Linked Server for MySQL. It works fine, but inside the trigger it shows the error message like
[OLE/DB provider returned
message: [MySQL][ODBC 3.51
Driver]Optional feature not
supported]
Msg 7391, Level 16,
State 1, Procedure ,
Line 6
The operation could not be performed because the OLE DB provider 'MSDASQL' was unable to begin a distributed transaction."
And this is my trigger,
alter trigger upd_test_enum
on mtest
for insert
as
begin
insert into emsdev...test_enum (id, name, is_active) values (4, 'Test4', 0)
end
Please help me.
Regard,
Mubarak
I had to do a few things to get it working. Also using a Win2K SQL server and importing data from MySql.
One thing we did was to install the 3.51.22 version of the MySql ODBC driver (mysql-connector-odbc-3.51.22-win32.msi).
Then the following article was very helpful: http://www.sqlservercentral.com/Forums/Topic340912-146-1.aspx
The main thing was to switch off transactions as well as to refer to the DSN when creating a Linked Server. For ease of reference I'll copy and paste the instructions from the SQLServerCentral article in this post below:
Creating a Linked Server in SSMS for a MySQL database
Download the MySQL ODBC driver from mysql.com
Install MySQL ODBC driver on Server where SQL Server resides -Double Click Windows Installer file and follow directions.
Create a DSN using the MySQL ODBC driver Start-> Settings -> Control Panel -> Administrative Tools -> Data Sources (ODBC) -Click
on the System DSN tab -Click Add -Select the MySQL ODBC Driver
-Click Finish On the Login Tab: -Type a descriptive name for your DSN. -Type the server name or IP Address into the Server text box.
-Type the username needed to connect to the MySQL database into the user text box. -Type the password needed to connect to the MySQL
database into the password text box. -Select the database you'd like
to start in. On the Advance Tab: Under Flags 1: -Check Don't Optimize
column width. -Check Return Matching Rows -Check Allow Big Results
-Check Use Compressed protocol -Check BIGINT columns to INT -Check Safe Under Flags 2: -Check Don't Prompt Upon Connect -Check Ignore #
in Table Name Under Flags 3: -Check Return Table Names for
SQLDescribeCol -Check Disable Transactions Now Test your DSN by
Clicking the Test button
Create a Linked Server in SSMS for the MySQL database SSMS (SQL Server Management Studio -> Expand Server Objects -Right Click Linked
Servers -> Select New Linked Server On the General Page: -Linked
Server: Type the Name for your Linked Server -Server Type: Select
Other Data Source -Provider: Select Microsoft OLE DB Provider for
ODBC Drivers -Product name: Type MySQLDatabase -Data Source: Type
the name of the DSN you created On The Security Page -Map a login to
the Remote User and provide the Remote Users Password -Click Add
under Local server login to remote server login mappings: -Select a
Local Login From the drop down box -Type the name of the Remote User
-Type the password for the Remote User
Change the Properties of the Provider MSDASQL Expand Providers -> Right Click MSDASQL -> Select Properties -Enable Nested queries
-Enable Level zero only (this one's the kicker) -Enable Allow inprocess -Enable Supports 'Like' operator
Change settings in SQL Server Surface Area Configuration for Features -Enable OPENROWSET and OPENDATASOURCE support.
Change settings in SQL Server Surface Area Configuration for Services and Connections -Enable Local and Remote connections via
TCP/IP and named pipes
Stop SQL Server and SQL Server Agent
Start SQL Server and SQL Server Agent
I didn't find I needed to restart the SQL server.

SQL Native Client, linked server error Only on Deletes

We are using a SQL Native Client to connect to a local SQL Server 2005 from a Borland application. It will fine for selects, inserts, and updates. When we delete we get the error:
Could not find server
SERVERNAME\SQLEXPRESS 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
The default instance, the only instance, is SERVERNAME\SQLEXPRESS, and we are not using linked servers. Any ideas? I believe we moved the MDF and LDF files to a new server for this DB, and then reattached it.
Update 1
There is no SQL. This is all happening through programmatic interaction with cursors. It is an ODBC driver using ADO. You run TableObj->Delete to remove the record.
Got it. I ran
SELECT ##servername
That returned the old host name of the box. I than ran
sp_dropserver 'OLDHOSTNAME\SQLEXPRESS'
go
sp_addserver 'NEWHOSTNAME\SQLEXPRESS', local
I then got
Server 'NEWHOSTNAME\SQLEXPRESS' is not
configured for DATA ACCESS
I ran
sp_serveroption 'ICS-POS3-NEW\SQLEXPRESS', 'data access' , 'true'
This got me the error
Transaction context in use by another
session
Which is because of linked servers. I found that the local option on the add server did not take affect until I restarted the server. I restarted, then it just worked.

Resources