Using linked server returns error - "Cannot obtain the schema rowset for OLE DB provider" - sql

I tried to move data aka ETL from one sql server to another as mentioned in a previous question - Copy data from one column into another column. Now, I get an error when I try to execute a query.
Query -
INSERT INTO [Target_server].[Target_DB1].[dbo].[Target_Table1](Target_Column1)
SELECT Source_Column222
FROM [Source_server].[Source_DB1].[dbo].[Source_Table1]
WHERE Source_Column1 = 'ID7162'
Error -
OLE DB provider "SQLNCLI" for linked server "MYLINKEDSERVER" returned message "Unspecified error".
OLE DB provider "SQLNCLI" for linked server "MYLINKEDSERVER" returned message "The stored procedure required to complete this operation could not be found on the server. Please contact your system administrator.".
Msg 7311, Level 16, State 2, Line 1
Cannot obtain the schema rowset "DBSCHEMA_TABLES_INFO" for OLE DB provider "SQLNCLI" for linked server "MYLINKEDSERVER". The provider supports the interface, but returns a failure code when it is used.

If your wrote that simple select is not working, the issue is in security configuration of the linked server and permissions which your user receive there.
Among this, when you execution your query, you don't need to specify the server name and DB name for both parts - source and target. You simply need to execute the query on target server and target database. In this case your query instead of
INSERT INTO [Target_server].[Target_DB1].[dbo].[Target_Table1](Target_Column1)
SELECT Source_Column222
FROM [Source_server].[Source_DB1].[dbo].[Source_Table1]
WHERE Source_Column1 = 'ID7162'
will looks like the following:
INSERT INTO [dbo].[Target_Table1](Target_Column1)
SELECT Source_Column222
FROM [Source_server].[Source_DB1].[dbo].[Source_Table1]
WHERE Source_Column1 = 'ID7162'
and you need your connection to be opened on server [Target_server] and database [Target_DB1]. Also the linked server security properties need to be checked on [Target_server] against the [Source_server].

If you are using loop back linked server (linked server refering to the same database in the same server) then refer the below mentioned link:
Transaction with loopback linked server - locking issues
If that is not the case, this is the solution provided by Microsoft.

Related

Unable to view one database

I am new to an organization, and there was a SQL Server link set up before I started between to servers. There are 12 databases on the linked server, and I can access all of them but one. For example, I run [SELECT * FROM [SERVER].Database.dbo.table1] and get a result set. And this is the case for all databases except 1. I run [SELECT * FROM [SERVER].Database2.dbo.table1] on that one and get "The OLE DB provider "SQLNCLI11" for linked server "SERVER" does not contain the table ""Database2"."dbo"."Table1"". The table either does not exist or the current user does not have permissions on that table. The table exists, and I am able to select from it on the originating server with no issues. I am logging in with windows authentication. Any ideas?
I have verified that I have the same database permissions on 1 that I can reference as the one I cannot.

Can't select column name from Eloquence database that has a forward slash in it (from a linked server in SQL Server)

My SQL Server instance has a linked server to an Eloquence database. I need to select data from one of the tables in the Eloquence database, but I need to do it with SQL syntax, since I'm running the code from SQL Server Management Studio (SSMS).
One of the columns has a forward slash in its name (I didn't create it, nor do I have the authority to change it), which throws the following syntax error when I run my query:
OLE DB provider [ProviderName] for linked server [LinkedServerName] returned message "Prepare: Syntax error or access violation {Syntax error in item list (select).}".
OLE DB provider [ProviderName] for linked server [LinkedServerName] returned message "Prepare: Syntax error or access violation {Expression syntax error in aggregate function.}".
Msg 7321, Level 16, State 2, Line 1
An error occurred while preparing the query "SELECT [TableName.ColumnName/WithForwardSlash] FROM [TableName]" for execution against OLE DB provider [ProviderName] for linked server [LinkedServerName].
I have tried:
Select * from.... throws the same error
Aliasing the column...throws the same error
Selecting the tablename.column name...throws the same error
Enclosing column name in brackets...throws the same error
Escaping the forward slash...throws 'Column not found' error
Note: I lack permissions to access the server directly, so I must query it via the linked server from SQL Server.
How can I select this column from SSMS via the linked server if it has a forward slash in it? How can I get around this error?
The SQL/R documentation: SQL/R A.03 Documentation

SQL Server : Linked Server row physical location

I can query the physical location of a row in Microsoft SQL Server by %%physloc%% identifier. For example like this
select %%physloc%% from [testdb].[dbo].[table1_t4];
I have created a linked server of this SQL Server instance with dbserv instance. I can query the row of this instance like:
select * from [dbserv].[testdb].[dbo].[table1_t4];
But when I query the physical location of the rows
select %%physloc%% from [dbserv].[testdb].[dbo].[table1_t4];
This throws the error:
Invalid column name '%%'.
How do I workaround by obtaining the physical location of the row of the linked server for my application?
Linked servers are all connected through OLE DB Providers like ODBC. While the "Virtual Column %%phys_loc%%" is an undocumented feature in SQL Server 2008. As such, OLE DB providers (barring the SQL Server native driver) aren't likely to support it, but I can't seem to find the documentation for it specifically.
Testing it out here, it also looks like it will only work when connected to the server locally, otherwise I get the same error you post here. Quoting the identifier throws an invalid column name error.
I don't believe you will be able to query this identifier through linked server at all.

OLE DB provider "Search.CollatorDSO" returns "Command was not prepared"

Has anybody been able to connect to Windows Search Service using the OLE DB Provider for Search in SQL Server? Below you'll find the error message I keep stumbling upon when configuring a Linked Server in Management Studio.
OLE DB provider "Search.CollatorDSO" for linked server "TESTSERVER" returned message "Command was not prepared.".
Msg 7399, Level 16, State 1, Line 2
The OLE DB provider "Search.CollatorDSO" for linked server "TESTSERVER" reported an error. Command was not prepared.
Msg 7350, Level 16, State 2, Line 2
Cannot get the column information from OLE DB provider "Search.CollatorDSO" for linked server "TESTSERVER".
I'm aware more people have been struggling with this problem over the last few years, but I haven't found a solution so far.
For reasons known only to Microsoft*, the Windows Search catalog is not accessible to SQL Server as an OLE DB datasource. The only feasible workaround for this issue is to create a CLR function and use it as a wrapper for querying the search catalog. A ready-to-run example can be found at http://www.nesterovsky-bros.com/weblog/2011/03/04/callingwindowssearchfromsqlserver2008.aspx.
*My best guess is that the search service is only partially SQL-compliant, in that it extends SQL-92 and SQL-99, but does not return the metadata or contain much of the functionality expected of a data source by SQL Server.

Error while connecting with QRemote using QODBC

Getting this error in SQL Server at a time of connecting to QREMOTE using QODBC
OLE DB provider "MSDASQL" for linked server "QREMOTE" returned message "Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done.
Please go to QODBC Setup screen --> Advanced tab --> Maximum Field Name Length --> Set " Maximum Field Name Length" to 70.
Also, Please Configure MSDASQL (Microsoft OLE DB Provider for ODBC Drivers)
[Note: MS SQL Express Edition do not have this setup options!!! ]
The OLE DB provider options for managing linked queries can be set in SQL Server Management Studio. In Object Explorer , right-click the provider name and select Properties for MSDASQL.
http://support.flexquarters.com/esupport/newimages/QRemoteSQLServer64Bit/image025.png
Dynamic parameter should be checked to allow parameter queries. Level zero only should be checked to allow four part naming to work. Allow InProcess should be checked to help performance.Non transacted updates should be checked if you want to be able to update QuickBooks data. Index as access path should be checked to help performance. Disallow adhoc accesses should be unchecked to allow OPENQUERY to function.
http://support.flexquarters.com/esupport/newimages/QRemoteSQLServer64Bit/image027.jpg
I would also like to suggest you to refer below mentioned link:
http://support.flexquarters.com/esupport/index.php?/Default/Knowledgebase/Article/View/2458/52/how-to-create-link-server-with-ms-sql-200520082012-64-bit-using-qodbcqremote
If you are still facing issue please create a support ticket at http://support.qodbc.com