What is provider string when configuring Linked Server - sql-server

I am configuring a linked server in SQL Server in order to send data from a SQL Server database to a MySQL database. While creating the linked server, in the fields to fill, I am asked the Provider string, unfortunately, I do not know what the Provider String is. Can somebody tell me what the Provider String is and how I can get it?
Here is a screenshot of the window where I need the Provider String

From the documentation Create Linked Servers (SQL Server Database Engine):
Provider string
Type the unique programmatic identifier (PROGID) of the OLE DB provider that corresponds to the data source. For examples of valid provider strings, see sp_addlinkedserver (Transact-SQL).
And then from that linked documentation:
[ #provstr = ] 'provider_string'
Is the OLE DB provider-specific connection string that identifies a unique data source. provider_string is nvarchar(4000), with a default of NULL. provstr is either passed to IDataInitialize or set as the DBPROP_INIT_PROVIDERSTRING property to initialize the OLE DB provider.
...
Remarks
The following table shows the ways that a linked server can be set up for data sources that can be accessed through OLE DB. A linked server can be set up more than one way for a particular data source; there can be more than one row for a data source type. This table also shows the sp_addlinkedserver parameter values to be used for setting up the linked server.
Remote OLE DB data source
OLE DB provider
product_name
provider_name
data_source
location
provider_string
catalog
SQL Server
Microsoft SQL Server Native Client OLE DB Provider
SQL Server 1 (default)
SQL Server
Microsoft SQL Server Native Client OLE DB Provider
SQLNCLI
Network name of SQL Server (for default instance)
Database name (optional)
SQL Server
Microsoft SQL Server Native Client OLE DB Provider
SQLNCLI
servername\instancename (for specific instance)
Database name (optional)
Oracle, version 8 and later
Oracle Provider for OLE DB
Any
OraOLEDB.Oracle
Alias for the Oracle database
Access/Jet
Microsoft OLE DB Provider for Jet
Any
Microsoft.Jet.OLEDB.4.0
Full path of Jet database file
ODBC data source
Microsoft OLE DB Provider for ODBC
Any
MSDASQL
System DSN of ODBC data source
ODBC data source
Microsoft OLE DB Provider for ODBC
Any
MSDASQL
ODBC connection string
File system
Microsoft OLE DB Provider for Indexing Service
Any
MSIDXS
Indexing Service catalog name
Microsoft Excel Spreadsheet
Microsoft OLE DB Provider for Jet
Any
Microsoft.Jet.OLEDB.4.0
Full path of Excel file
Excel 5.0
IBM DB2 Database
Microsoft OLE DB Provider for DB2
Any
DB2OLEDB
See Microsoft OLE DB Provider for DB2 documentation.
Catalog name of DB2
So you can choose the appropriate value of the provider from the OLEDB source you are using for your linked server.

Related

Can't create linked server from microsoft SQL to Snowflake

Created DNS and installed ODBC Drivers followed same steps from below URL
https://snowflakecommunity.force.com/s/article/how-to-set-up-a-linked-server-from-sql-server-to-snowflake
Once creating testing connection at last step it shows error like
OLE DB provider "MSDASQL" for linked server "SNOWFLAKEDATA" returned message "[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified". (Microsoft SQL Server, Error: 7303)
But DNS created and used followed same way in URL. Can i know where I made mistake?
Please ensure to create the linked server to Snowflake with the following information:
Provider: This should be "Microsoft OLE DB Provider for ODBC Drivers."
Data Source: This should match the ODBC system/user DSN name that was previously configured
Under the Security Tab on left panel, make sure to add a local login (your local machine's login including your host name) associated to a remote user (snowflake username) and its matching password.

SQL Server: link DB2 table

I would like to query a DB2 table in SQL Server. Is it possible to link a DB2 table in SQL Server?
I do not have that much experience with SQL Server and could not find much documentation on this subject. Any help would be appreciated!
I would like to query a DB2 table in SQL Server. Is it possible to link a DB2 table in SQL Server?
This is possible by involving linked servers
Example of SQL to create a linked server object:
EXEC sp_addlinkedserver
#server = 'WNW3XX',
#srvproduct = 'Microsoft OLE DB Provider for DB2',
#catalog = 'OLYMPIA',
#provider = 'DB2OLEDB',
#provstr='NetLib=SNA;NetAddr=;NetPort=;RemoteLU=OLYMPIA;LocalLU=LOCAL;ModeName=QPCSUPP;User ID=WNW3XX;Password=WNW3XX;InitCat=OLYMPIA;Default Schema=WNW3XX;PkgCol=WNW3XX;TPName=;Commit=YES;IsoLvl=NC;AccMode=;CCSID=37;PCCodePage=1252;BinAsChar=NO;Data Source=Olympia_WNW3XX'
EXEC sp_addlinkedsrvlogin 'WNW3XX', false, NULL, 'WNW3XX', 'WNW3XX'
And a sample query to a remote object on DB2 instance:
SELECT * FROM WNW3XX.OLYMPIA.WNW3XX.DEPARTMENT
The answer is based on:
Creating a linked server to DB2 using Microsoft OLE DB provider for DB2
Other references:
https://www.mssqltips.com/sqlservertip/2151/how-to-create-a-sql-server-link-server-to-ibm-db2/
http://www.sqlcoffee.com/Tips0013.htm
How to add an IBM DB2 server to SQL Server's Linked Server
Starting from SQL Server 2019 CTP 2.0 you could use also PolyBase:
What is PolyBase?
PolyBase enables your SQL Server instance to process Transact-SQL
queries that read data from external data sources. SQL Server 2016 and
higher can access external data in Hadoop and Azure Blob Storage.
Starting in SQL Server 2019 CTP 2.0, you can now use PolyBase to
access external data in SQL Server, Oracle, Teradata, and MongoDB.
The same queries that access external data can also target relational
tables in your SQL Server instance. This allows you to combine data
from external sources with high-value relational data in your
database. In SQL Server, an external table or external data source
provides the connection to Hadoop.
Configure PolyBase to access external data in Teradata as example:
CREATE DATABASE SCOPED CREDENTIAL credential_name
WITH IDENTITY = 'username', Secret = 'password';
CREATE EXTERNAL DATA SOURCE external_data_source_name
WITH (LOCATION = teradata://<server address>[:<port>],
-- PUSHDOWN = ON | OFF,
CREDENTIAL =credential_name);
CREATE EXTERNAL TABLE ...;
SELECT * FROM external_table_name;
CREATE EXTERNAL DATA SOURCE
LOCATION = '://'
Provides the connectivity protocol and path to the external data source.
ODBC odbc [:port] Starting with SQL Server 2019 (15.x) - Windows only
CREATE EXTERNAL TABLE

How to connect to SQL Server 2014 installed on one PC from a 2nd PC without Windows server and domain involved?

I have a Toshiba laptop with Windows 7 on which I have installed SQL Server 2014 for my database and use Microsoft Access 2016 to manage the data in a user-friendly way.
Everything worked perfectly fine till I tried to connect to the database from another PC on the same network, also with Windows 7.
I am able to connect to the database from the second PC using Microsoft SQL Server Management Studio and SQL Server Native Client 11.0, logging in as sa using SQL Server authentication.
However, when I open the Microsoft Access database file from the second PC, a window pops up, saying that:
See this image.
And when I press OK a second window pops:
See this image.
I have configured the database to use a specific TCP/IP = 1433
Also made new inbound rules in windows firewall for all SQL Server services.
Please note that there is no domain involved here. I don't have a Windows server and the SQL Server is installed on PC #1.
If you require more information, please tell me, I'll be happy to provide
Hope someone will be able to help!
try to use LINKSERVER
Using SQL Server Management Studio
To create a linked server to another instance of SQL Server Using SQL Server Management Studio
In SQL Server Management Studio, open Object Explorer, expand Server Objects, right-click Linked Servers, and then click New Linked Server.
On the General page, in the Linked server box, type the name of the instance of SQL Server that you area linking to.
SQL Server
Identify the linked server as an instance of Microsoft SQL Server. If you use this method of defining a SQL Server linked server, the name specified in Linked server must be the network name of the server. Also, any tables retrieved from the server are from the default database defined for the login on the linked server.
Other data source
Specify an OLE DB server type other than SQL Server. Clicking this option activates the options below it.
Provider
Select an OLE DB data source from the list box. The OLE DB provider is registered with the given PROGID in the registry.
Product name
Type the product name of the OLE DB data source to add as a linked server.
Data source
Type the name of the data source as interpreted by the OLE DB provider. If you are connecting to an instance of SQL Server, provide the instance name.
Provider string
Type the unique programmatic identifier (PROGID) of the OLE DB provider that corresponds to the data source. For examples of valid provider strings, see sp_addlinkedserver (Transact-SQL).
Location
Type the location of the database as interpreted by the OLE DB provider.
Catalog
Type the name of the catalog to use when making a connection to the OLE DB provider.
http://www.quackit.com/sql_server/sql_server_2014/tutorial/linked_servers.cfm

Export Data from SQL Server 2014 to Excel

I tried to export data from SQL Server 2014 to Excel.
I tried like this
insert into OPENROWSET('Microsoft.ACE.OLEDB.12.0', 'Excel 12.0
Xml;HDR=YES;Database=D:\testing.xlsx;',
'SELECT OI_NAME,OI_ADDRESSS FROM [Sheet1$]') select OI_NAME,
OI_ADDRESSS from OI_TEMP
But I get this error
OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server "(null)" returned message "Unspecified error".
Msg 7303, Level 16, State 1, Line 1
Cannot initialize the data source object of OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server "(null)".
I searched on the internet, and found this:
The SQL Server Error Message if a user have no rights for SQL Server TEMP directory OLE DB provider "Microsoft.Jet.OLEDB.4.0" for linked server "(null)" returned message "Unspecified error".
Msg 7303, Level 16, State 1, Line 1
Cannot initialize the data source object of OLE DB provider "Microsoft.Jet.OLEDB.4.0" for linked server "(null)".
But I assign permission is still does not work.
Why?
To export data from SQL to Excel, you need to follow 2 steps:
Step 1: Connect Excel to your SQL database‍ (Microsoft SQL Server, MySQL, PostgreSQL...)
Step 2: Import your SQL data into Excel
The result will be the list of tables you want to query data from your SQL database into Excel:
Step1: Connect Excel to an external data source: your SQL database
Install An ODBC
Install A Driver
Avoid A Common Error
Create a DSN
Step 2: Import your SQL data into Excel
Click Where You Want Your Pivot Table
Click Insert
Click Pivot Table
Click Use an external data source, then Choose Connection
Click on the System DSN tab
Select the DSN created in ODBC Manager
Fill the requested username and password
Avoid a Common Error
Access The Microsoft Query Dialog Box
Click on the arrow to see the list of tables in your database
Select the table you want to query data from your SQL database into Excel
Click on Return Data when you’re done with your selection
To update the export automatically, there are 2 additional steps:
Create a Pivot Table with an external SQL data source
Automate Your SQL Data Update In Excel With The GETPIVOTDATA Function
I've created a step-by-step tutorial about this whole process, from connecting Excel to SQL, up to having the whole thing automatically updated. You might find the detailed explanations and screenshots useful.
I try on a few years ago, do it that way and it was not possible, I suggest you use this form to export data to Excel from SQL -server.
Font: Microsoft Developer Network
Create an excel file, then option Data -> From other source -> From SQL Server
Select input your server, user and password, then select database and choose your table.
See this video:
Video Tutorial - SQL server to Excel
Then, you can code a macro on VBA to update automatically excel file
sub Auto_Open ()
ActiveWorkbook.RefreshAll
end sub
I hope this help to you!

Error querying "Microsoft.ACE.OLEDB.12.0" provider from SQL Server

This is not a question, but this post may be useful for community because I could not find the answer on the Internet.
Tested on
Windows 2008 R2 x64 and Windows 2003 x64
SQL Server 2008 SP3 x64
Provider Microsoft.ACE.OLEDB.12.0 x64
SQL Server is running under domain account that is not admin of local machine.
SQL Server connection authentication is Windows.
The issue is:
when creating and using a linked server or adhoc querying using this provider, you may receive errors like these:
OLE DB provider "MSDASQL" for linked server "xxx" returned message "[Microsoft][ODBC Driver Manager] Driver's SQLSetConnectAttr failed"
OLE DB provider "MSDASQL" for linked server "xxx" returned message "[Microsoft][ODBC dBASE Driver] Your network access was interrupted. To continue, close the database, and then open it again.
Cannot initialize the data source object of OLE DB provider "MSDASQL" for linked server "xxx"
Could not find installable ISAM
OLE DB provider "MSDASQL" for linked server "xxx" returned message "[Microsoft][ODBC dBASE Driver]General error Unable to open registry key Temporary (volatile) Ace DSN for process 0x16f4 Thread 0x2728 DBC 0x1ce64ae8 Xbase'
The reason is that the provider creates a temporary file in SQL Server's domain account's temporary folder, using user connect's credentials. Ordinary users does not have such permissions.
The solution is
grant "Modify" permission to sql server users on Sql Server's domain account's temporary folder.
This folder ordinarily is
Windows 2003: "c:\Documents and
Settings\sql_server_account_name\Local Settings\Temp\"
Windows 2008: "C:\Users\sql_server_account_name\AppData\Local\Temp\"

Resources