VB.NET DataSet not working with view with linked SQL Server - sql-server

I am in DataGrid hell right now but that's another post.
Anyway, I wrote a view with a union query in SQL Server that grabs data from a linked SQL server.
Anytime I try to add this object as a dataset in VB.NET it completely bombs out on me with this ugly error message...
ERROR [42000] [Microsoft] [ODBC SQL Server Driver] [SQL Server] The operation could not be performed because the OLE DB Provider 'SQLOLEDB' was unable to begin a distributed transaction. ERROR [01000] [Microsoft] [ODBC SQL Server Driver] [SQL Server] [OLE/DB provider returned message : new transaction cannot enlist in the specified transaction coordinator] ERROR [01000] [Microsoft] [ODBC SQL Server Driver] [SQL Server] OLE DB Error Trace [OLE/DB Provider 'SQLOLEDB' lTransactionJoin::JoinTransaction returned 0x8004d00a]
I'm completely stumped as to why I can't create a dataset from a view that references a linked SQL server. It's not this specific view either, all views that reference this linked server bomb out.
Any ideas?
Thanks.

This simple answer is to enable MSDTC on the servers. As to why this is happening on your views, I'm not entirely sure. There are also some good trouble shooting tips here.

Related

OLE DB error: OLE DB or ODBC error: Incorrect syntax near the keyword 'JOIN'.; 42000

Our cubes were working fine and were processed daily in SSMS until some Microsoft security updates were installed & the server was restarted. We receive the error message above when processing the cubes and dimensions. We already deleted the security updates but we still get the same error.
In the windows services -> SQL Server Analysis we have a service account with all the rights in SQL server (read, write, process, admin). We are working on SQL Server 2014.
We tried to:
restart the SQL Server Analysis
set up new accounts with read,process and admin rights on the SQL server and analysis server.
we tried to put in the "SQL Server Analysis" to put the Local account
create a new cube but Dimension can still not be processed.
change the provider from "SQL Server Native Client 11.0" to "Microsoft OLE DB Provider for SQL server" and we also checked the "allow inprocess" checkbox in SSMS in Server Objects -> Linked Servers -> Providers.
Nothing worked of the points above. I hope someone can help us.
Error message:
OLE DB error: OLE DB or ODBC error: Incorrect syntax near the keyword
'JOIN'.; 42000. Errors in the OLAP storage engine: An error occurred
while the dimension, with the ID of
'd4b8c9a6-7692-4d64-bb9c-f4ac7d7d62d1', Name of 'Customer' was being
processed. Errors in the OLAP storage engine: An error occurred while
the 'Type' attribute of the 'Customer' dimension from the 'TestCube'
database was being processed. Server: The current operation was
cancelled because another operation in the transaction failed.
Details:
Internal error: The operation terminated unsuccessfully. ... Module:
Microsoft.AnalysisServices
Microsoft.AnalysisServices.OperationException
at Microsoft.AnalysisServices.AnalysisServicesClient.SendExecuteAndReadResponse(ImpactDetailCollection
impacts, Boolean expectEmptyResults, Boolean throwIfError)
at Microsoft.AnalysisServices.Server.Process(IMajorObject obj, ProcessType processType, Binding source, ErrorConfiguration
errorConfig, WriteBackTableCreation writebackOption,
XmlaWarningCollection warnings, ImpactDetailCollection impactResult,
Boolean analyzeImpactOnly)
at Microsoft.AnalysisServices.Server.SendProcess(IMajorObject obj, ProcessType processType, Binding source, ErrorConfiguration
errorConfig, WriteBackTableCreation writebackOption,
XmlaWarningCollection warnings, ImpactDetailCollection impactResult,
Boolean analyzeImpactOnly)
at Microsoft.AnalysisServices.ProcessableMajorObject.Process(ProcessType
processType, ErrorConfiguration errorConfiguration,
XmlaWarningCollection warnings)
at TimeXtender.DataManager.CubeEngine_2005.ProcessDimension(Dimension
dimension)
FYI:
We finally managed to fix the problem.
When running the SQL server repair it failed on SSAS with an error that indicates that the installation of SSAS was never successful so we think the files were corrupted.
Then we installed another instance of SSAS only to have 2 SSAS services. The new one was working so we deleted the old one and replaced it with a new SSAS installation. So no need reinstall the complete SQL Server.
We did backups just in case we would need them but all the cubes were automatically found by the new SSAS instance in that folder that we indicated in the installation process.
Everything was immediately working.

SQL linked server Python pyodbc insert error

I'm having an interesting error when I'm trying to trigger an SP on a local SQL Server with two linked servers.
The purpose of the exorcise above is to move data from one linked server to another.
When I'm triggering the stored procedure from SSMS it works like a charm, but when I trigger it from Python I'm getting these sexy error messages:
(
'42000', '[42000] [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]The OLE DB provider "SQLNCLI11" for linked server "XXXX" reported an error. One or more arguments were reported invalid by the provider. (7399) (SQLExecDirectW)
; [42000] [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]The operation could not be performed because OLE DB provider "SQLNCLI11" for linked server "XXXX" was unable to begin a distributed transaction. (7391)
; [42000] [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]OLE DB provider "SQLNCLI11" for linked server "XXXX" returned message "The parameter is incorrect.". (7412)'
)
In short my python scripts (that fails with the errors above) looks as follows:
MyConn = pyodbc.connect(DRIVER="ODBC Driver 17 for SQL Server",SERVER=os.environ["sqlServer"],UID=os.environ["sqlUID"],DATABASE=os.environ["sqlDB"],PWD=os.environ["sqlPWD"])
Cursor = MyConn.cursor()
sqlQuery = "exec dbo.usp_XXXXETL #LookBackDays = 0"
Cursor.execute(sqlConta)
I've also tested the connection above; I'm able to run select statements against the linked servers from python.
What's even more annoying is that when I write it in R it works:
conn = odbcDriverConnect("Driver={ODBC Driver 17 for SQL Server};Server=*SameServer*;Database=*SameDB*;Uid=*Uid*;Pwd=*Pwd*;Connection Timeout=360;")
sqlExecute(
conn,
query="dbo.usp_XXXXETL #LookBackDays = 0",
fetch=FALSE,
errors=TRUE,
query_timeout=300)
Obviously it works so it's no big problem, it's just that I hate R-scrips and am sort of puzzled by the error.
In advance many thanks for your time and brain power!
You've started a transaction, and the linked server is configured to enlist the remote server in the transaction, which required MSDTC. So
1) Don't start a transaction. You've probably got autocommit off, which causes the session to use implicit transactions.
2) Disable the remote proc transaction promotion option for the linked server with sp_serveroption
3) Troubleshoot MSDTC to enable the distributed transaction.

OLE DB error: OLE DB or ODBC error:

I am trying to connect from my SSAS server to SQL through SSMS and the connection works fine when I test it. But when I am processing the cube, I am getting the below error message.
OLE DB error: OLE DB or ODBC error: A network-related or instance-specific error has occurred while establishing a connection to SQL Server. Server is not found or not accessible. Check if instance name is correct and if SQL Server is configured to allow remote connections. For more information see SQL Server Books Online.; 08001; Client unable to establish connection; 08001; Encryption not supported on the client.; 08001.
I have looked the other similar error message that was posted and tried the below options as per the suggestions.
SSAS - OLE DB error in establishing a connection
1. Restart SSAS Service
2. Restart SSAS using local system
3. Trying to change the Provider to Native OLE DB\Microsoft OLE DB Provider for SQL server, but still I am getting the below error
OLE DB error: OLE DB or ODBC error.
I am stuck with this for more than 3 days and not able to progress anything beyond. I tried all other Providers as well and still it doesn't work.
Additionally I made sure that the Windows account I am using in data source of SSAS server is having db_owner on the SQL data base.
Any help would be really appreciated to get me out of this.
I was able to get a solution for this upon trial and error method for selecting the below changes. I have tried to set the
1. Provider as "Native OLE DB/Microsoft OLE DB Provider for SQL Server"
2. Changed the connection from Windows Authentication to SQL connection.
3. The type of Impersonate Account from Windows Authentication to Authenticate by Service Account.
Once the above settings were done, I was able to process the Cube.

How to fix Linked Server from SQL Server 2016 to Oracle 12c?

I set up a few weeks ago a linked server in my sql server 2016 to my oracle 12c following this guide. It was working properly, but after some windows updates that restarted my machine, it no longer works. I can log into oracle properly through sqlplus and sql developer, but not through sql server. I get the following error:
OLE DB provider "OraOLEDB.Oracle" for linked server "LINKED_ORACLE" returned message "ORA-12154: TNS:could not resolve the connect identifier specified".
Msg 7303, Level 16, State 1, Line 1
Cannot initialize the data source object of OLE DB provider "OraOLEDB.Oracle" for linked server "LINKED_ORACLE".
I restarted the SQL Server service, as well as restarted windows again, but still same error. What could have changed in a single restart? How can I fix it and get the linked server working again?
For some reason, SQL SERVER was properly reading the tnsnames.ora file before the restart, but after the restart it stopped. I had to recreate the linked server, and put the whole connection string in the Data Source field for it to work again.
Sample Data Source found here:
Data Source=(DESCRIPTION=(CID=GTU_APP)(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST= server01.mydomain.com)(PORT=1521)))(CONNECT_DATA=(SID=OracleDB)(SERVER=DEDICATED)));

Creating a view from another Server error

Hi All I am trying to create a View from another database server...
I have have got server A an din Server A is where i want to create a view referencing a table from Server B.... when I run the command below:
create view TableFromServerB as select * from ServerB.master.information_schema.table;
I get the following error:
OLE DB provider "SQLNCLI11" for linked server "ServerB" returned
message "Login timeout expired". OLE DB provider "SQLNCLI11" for
linked server "ServerB" returned message "A network-related or
instance-specific error has occurred while establishing a connection
to SQL Server. Server is not found or not accessible. Check if
instance name is correct and if SQL Server is configured to allow
remote connections. For more information see SQL Server Books
Online.". Msg 53, Level 16, State 1, Line 0 Named Pipes Provider:
Could not open a connection to SQL Server [53].
I have done some research online and i came to a source that suggested using sp_addlinkedserver in my command .. which i have done and when i did this it said server already exists . So is there anything i am missing out here??
I have seen an issue like this before:
Can you please do something like this:
Create a view in your linked server to access the object i.e master.information_schema.table;
Use this view in the queries from the server where you want to display the results.
Eg:
--- create view script--
create view dbo.vINFORMATION_SCHEMATABLES
as
SELECT *
FROM INFORMATION_SCHEMA.TABLES
go
-- select statement from local server
select * from [testSRV].[testDB_far].[dbo].[vINFORMATION_SCHEMATABLES]
Let me know if this helps.

Resources