I've got 2 servers in a workgroup called "workgroup".
Server A is W2012R2 with SQL Server 2012.
Server B is W2012R2 with other application. SQLCMD Utility has been installed on server B.
I'm using local account, SQL service is start by local account. I can connect to the SQL server from B to A. I can launch query without difficulty. When I launch my SQL script, I get the following error:
E:\Batch\Script>sqlcmd -S YMSQL01 -i test.sql
Changed database context to 'PROD'.
Msg 7399, Level 16, State 1,
Server YMSQL01, Procedure V_C_Prod, Line 3 The OLE DB provider
"Microsoft.ACE.OLEDB.12.0" for linked server "C_PROD" reported an
error. The provider did not give any information about the error.
Msg 7303, Level 16, State 1, Server YMSQL01, Procedure V_C_Prod, Line 3
Cannot initialize the data source object of OLE DB provider
"Microsoft.ACE.OLEDB .12.0" for linked server "C_PROD".
As you can see, it seems that I cannot query on a view. This view is from a linked server which is connected to an Excel file (located on server B). I have installed the same ODBC driver on server B but I get the same error.
My SQL script:
Use PROD
Go
Merge dbo.conc AS t
using V_C_Prod as s
ON (t.CodeComptable=s.[Code Comptable])
WHEN MATCHED THEN UPDATE SET
t.[Marque]=s.[Marque]
,t.[CodeHolding] = s.[Code HOLDING]
,t.[Email1]=s.[Email Principal]
,t.[CP]=s.[CP]
,t.[Ville]=s.[Ville]
WHEN NOT MATCHED
THEN INSERT VALUES (
s.[Marque]
,s.[Code HOLDING]
,s.[Code Comptable]
,s.[Email Principal]
,s.[CP]
,s.[Ville];
Go
How can I solve this issue?
Related
I am trying to connect to SQL Azure database from an on-premise SQL Server using openrowset, but it is failing with an error.
My query is
SELECT a.*
FROM OPENROWSET('SQLNCLI', 'Server=sqlazureserver.database.windows.net;Database=dbname;User ID=username;Password=password;Connection Timeout=30;', 'select * from [dbo].[tablename]') AS a;
and the error I get:
Msg 7399, Level 16, State 1, Line 11
The OLE DB provider "SQLNCLI11" for linked server "(null)" reported an error. Authentication failed.
Msg 7303, Level 16, State 1, Line 11
Cannot initialize the data source object of OLE DB provider "SQLNCLI11" for linked server "(null)".
I am able to successfully connect using linked server, but I do not want to go that route as my connection strings will be dynamic.
From documentation ,I could see open row set is not supported against SQL Azure database as of now.
Instead of openrowset,you can use distributed queries to accomplish the same
exec ('select * from table') at linkedserver
I have a local SQL Server 2012, and a vendor has a remote SQL Server 2012 setup for us with a read only SQL user. The vendor will do nothing except provide this read only login. I can login and query with remote credentials all day long. But, when connected to my instance, I can't query the vendor instance. I need to query and run jobs from my server, but can't.
Here's some info on what I can and can't do:
Login with their credentials and run queries:
Server: Some.I.P.Address\SomeName
U: ReadOnlyUser
P: ThePassword
I Created a linked server with my local logins and the above remote user which will pass a connection test.
From my server I can query a remote system table, but not the remote user tables:
Meaning I CAN NOT do this:
Select top 1 * from [Some.I.P.Address\SomeName].DateBaseName.ReadOnlyUser.[TableName]
But I CAN do this:
SELECT top 1 * FROM [Some.I.P.Address\SomeName].master.sys.Servers
How come I can connect directly to the remote instance and run queries, but when I am connected to my server I can only query the system tables?
It gives me this error, but A) the table does exist, and B) the user does have permissions because I can connect directly with the same credentials that pass the linked server connection test and run a query on that table.:
Msg 7314, Level 16, State 1, Line 1
The OLE DB provider "SQLNCLI11" for linked server "[Some.I.P.Address\SomeName]" does not contain the table ""DateBaseName"."ReadOnlyUser"."TableName"". The table either does not exist or the current user does not have permissions on that table.
I have set up a linked server from SQL Server 2008 R2 to an Excel spreadsheet, from which I read the contents in to a table, for comparison during an import.
The spreadsheet is held on a network share from an application server.
Basically, this works perfectly on the SQL Server when I run:
SELECT * FROM SpreadsheetLink...[CONTENTS$]
However, as I now need to schedule this, I need to create an SSIS package on the application server, which runs the same query.
So now, whenever I try to do this though (either by writing the script in to SSIS or by logging in to SQL Server Mgmt Studio on the App server and then opening an SQL connection to the SQL Server and querying directly) I get an error:
Msg 7399, Level 16, State 1, Line 1
The OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server "SpreadsheetLink" reported an error. The provider did not give any information about the 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 "SpreadsheetLink"
I first wondered whether I had forgotten to install OLEDB12.0 on the application server, but it is there.
I next wondered whether it was a permissions issue, so I added the EVERYONE group, with "Full Control" to the folder containing the spreadsheet and also ensured that the account that I am both logged in with and running the query as is an administrator on both the SQL server and the Application Server.
I also checked that the account was a member of the Distributed COM user group on both servers (it was).
Additional info:
I have tried several things, but it still fails.
I added the following
sp_configure 'show advanced options', 1
GO
RECONFIGURE
GO
sp_configure 'Ad Hoc Distributed Queries', 1
GO
RECONFIGURE
I then re-tested, but got the same results (success from the local SQL server, failure from the other server).
Next, I tried creating a different query, referring to the spreadsheet directly by path, rather than by Link-name, but that resulted in exactly the same outcome:
SELECT * INTO TargetTableName FROM OPENROWSET('Microsoft.ACE.OLEDB.12.0',
'Excel 12.0;Database=\\SERVER_NAME\PATH\fileName.xls;HDR=YES',
'SELECT * FROM [sheetName$]')
I also applied all of the suggestions in the following page:
http://visakhm.blogspot.co.uk/2013/12/how-to-solve-microsoftaceoledb120-error.html. But still no joy.
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.
I've successfully connected to an Azure hosted SQL database in SQL Server Management Studio, but I can't perform any queries that I can perform in web matrix.
The following query works just fine in web matrix:
SELECT *
FROM [junglegymSQL].dbo.Action AS a
But when I try to execute it in SQL Management Studio I receive the following error:
Msg 40515, Level 15, State 1, Line 16
Reference to database and/or server name in 'junglegymSQL.dbo.Action' is not supported in this
version of SQL Server.
Remove the [junglegymSQL] from your SQL.