I'm working on a project that involves capturing data from an external service and relaying it into an IBM DB2 database. Data captured by the Web API is stored in SQL Server via Entity Framework 6 code. The table in SQL Server was structured after an existing table in DB2, using a generated script from System i Navigator to create an ISO Standard create script.
Remote Service --> Web API --> SQL -/-> DB2
The DB2 Server is set up as a linked server. I am able to select from its libraries and perform inserts manually from SQL Server Management Studio.
My goal is to run a query of the form:
INSERT INTO LinkedServer.SCHEMA.Table (Column1, Column2, Column3,...)
SELECT
(Column1, Column2, Column3,...)
FROM
database.dbo.Table
However, when I attempt to run the above query, I am met with messages like these:
OLE DB provider "IBMDASQL" for linked server "SERVER" returned message "CWBZZ5014 Value of parameter PARAMETER could not be converted to the host data type.".
OLE DB provider "IBMDASQL" for linked server "SERVER" returned message "CWBZZ5013 Cannot convert from CCSID 13488 to CCSID 937.".
OLE DB provider "IBMDASQL" for linked server "SERVER" returned message "CWBZZ5013 Cannot convert from CCSID 1202 to CCSID 937.".
I think there is something weird about how the insert statement is handling character encoding for all of the char(N) columns in the table, but I have no idea what to do about it. Have I missed something?
Related
I have access to an Oracle database and I need to bring its data into SQL Server. The table has a simple structure and I can't change anything on the Oracle side.
I created a linked server inside SQL Server but I can't select the table because of this error :
The OLE DB provider "OraOLEDB.Oracle" for linked server supplied inconsistent metadata for a column. The column (compile-time ordinal 1) of object was reported to have a "DBCOLUMNFLAGS_ISFIXEDLENGTH" of 16 at compile time and 0 at run time
The OLE DB provider "OraOLEDB.Oracle" for linked server supplied inconsistent metadata for a column. The column (compile-time ordinal 1) of object was reported to have a "DBCOLUMNFLAGS_ISFIXEDLENGTH" of 16 at compile time and 0 at run time
I checked and it seems to be a general problem and Oracle suggested using OPENQUERY to get data from these tables.
When I use OPENQUERY the IMAGE ( 'BFILE' ) column is null but I can see in SQL Developer that it is not null.
When I use SSIS, I get this error:
ADO NET Source [33]] Error: The error "ORA-00972: identifier is too long occurred while processing "ADO NET Source.Outputs[ADO NET Source Output].Columns[IMAGE]
Any ideas on how to move a table with an IMAGE (BFILE) column from Oracle database to SQL Server?
I have changed variable names to protect customer.
I am trying to execute a stored procedure from a remote Oracle 12c database, from my SQL Server 2012 database. If it helps, the Oracle database pl/SQL procedure is has input data types of: INPUT1=CHAR(200), INPUT2=(NUMBER), OUTPUT=SYS_REFCURSOR
I am constantly getting the following error:
"OLE DB provider "OraOLEDB.Oracle" for linked server "testsrv1" returned message "Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done.""
My query is found below:
DECLARE #outputParameter int
DECLARE #inputParameter varchar(400)
DECLARE #inputParameter1 varchar(400)
set #inputParameter1 = 'SampleStringValue'
set #inputparameter = SampleNumberValue
EXEC ('BEGIN storedProcedure(?,?); END;', #inputParameter, #inputParameter1, #outputParameter OUTPUT) at testsrv1
After many hours of research, I found that you cannot return a SYS_REF_CURSOR data type over a database link. Even from an Oracle database to another Oracle database.
https://asktom.oracle.com/pls/apex/asktom.search?tag=returning-result-set-from-stored-procedure-over-a-database-link
If Oracle database A is the DB producing the SYS_REF_CURSOR, and database B is the consumer - the only way that I have found online is to retrieve the data inside database A and store into a table, then pass the table via database link.
Is this really the only way to do this? I am somewhat new to oracle, but this seems like something that should be able to be done by now. The link from above is from 10+ years ago.
You can use SSIS and the SSIS Data Streaming Destination to connect to Oracle in SSIS and consume the output of the SSIS package in a SQL Query.
From SSIS you can use OleDB, ODBC, ADO.NET connectors for Oracle, or you can use a .NET script to connect to Oracle.
how can i copy data from a view of one server into the database table of another server in a SQL server database without using linked servers method.
I tried using the code:
SELECT [LogEntryID]
,[TimeStamp]
Into [server-2].[database1].[dbo].[table1]
FROM [server-1].[database1].[dbo].[view_1]
I recieve the error " The object name 'server-2.database1.dbo.table1' contains more than the maximum number of prefixes. The maximum is 2.
The copying statement i am using in a groovy code. But for first i am trying it in a query if it works.
You can use opendatasource instead of linked server
insert DestinationTable
select * from opendatasource('SQLOLEDB', 'Server=SourceServer;User Id=Username;Password=Password;').SourceDb.Schema.SourceTable;
OPENDATASOURCE
I used the Microsoft OLE DB Provider for SQL Anywhere to create a linked server, it shows remote databases and tables, I can read data, but writing data seems to work only using OPENQUERY() and when doing the connection_authentication using EXEC ... AT ... directly in the script.
How can I have the SQL Server do the authentication automatically when opening a connection?
How can I make normal write operations work without OPENQUERY()?
Sorry for not adding detailed error messages, I will add them later maybe, when I have access to the server again... But they were not meaningful anyway, i.e. when the weird authentication was missing, it just said "could not insert" or "failed" instead of indicating any authentication issue.
How to get the real error messages that come from Sybase?
Details:
SAP Sybase SQL Anywhere 16 (OEM Authenticated Edition) <-> MS SQL Server 2014
EXEC 'SET TEMPORARY OPTION CONNECTION_AUTHENTICATION=''Company=...''' AT linkedserver
INSERT INTO OPENQUERY(linkedserver, 'SELECT column FROM table WHERE 0=1') VALUES ('')
...that's not nice.
Even more details:
This is how I created the linked server
This is the authentication I'm talking about
I have been trying for the past week or so to import data programmatically to a SQL Server 2008 table from a Microsoft Access .mdb file. I have been getting nothing but errors, and solving one just reveals another. I made the file into a linked server, and now when I try to query it with:
Select * from OPENQUERY(Importdata, 'Select * from [IMBPieceBC]')
I get the error:
OLE DB provider "Microsoft.Jet.OLEDB.4.0" for linked server "Importdata" returned message "Cannot open database ''. It may not be a database that your application recognizes, or the file may be corrupt.".
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 "Importdata".
I've read several suggestions to relink dlls in the registry, but I've done that, and I'm still getting the error. Is there anything else I can do to fix it, or at least figure out what is wrong?
Migrating the data to a SQL Server instance is not an option. The mdb files are generated by a third-party program, so there's nothing we can do about it.
I have a similar situation at my workplace - a third party application that maintains data in MDBs, but other applications needing access to it. How I've done it is that this 'intermediary' application has links to the SQL Server tables and the MDB tables. You could use either a query or a VBA written form event to transfer information from the MDB table(s) involved into your corresponding SQL Server tables using a INSERT INTO query, fitted with a SELECT FROM subquery providing the values being inserted.