Bulk Insert Task Error in ssis - sql-server

While running ssis Bulk insert i got the following error.
An error occurred with the following error message: "Cannot fetch a row from OLE DB provider "BULK" for linked server "(null)".The OLE DB provider "BULK" for linked server "(null)" reported an error. The provider did not give any information about the error.The bulk load failed. The column is too long in the data file for row 1, column 1. Verify that the field terminator and row terminator are specified correctly.".
To solve the problem i have change the connection timeout to 0 and to 5 . That did not work .
I also reviewed the data on row 1 column 1.

"In order to avoid these kinds of issues, I always import all fields as varchar fields into a staging table, then convert them into the data type required. You will have much more control."
You can get more details from the following link:
https://social.msdn.microsoft.com/Forums/sqlserver/en-US/5caa8c0a-2328-4c9e-9894-eaba12e8196a/data-conversion-error-during-bulk-insert?forum=sqlgetstarted

Related

Insert Statement error returned message "the driver cound't identify inserted rows"

I am transferring the data from the local SQL server to a remote (PostgreSQL) table using a Linked server (ODBC). This works perfectly as long as I stick with Select query but fails with Insert, Delete, etc.
Error :
OLE DB provider "MSDASQL" for linked server "DDL_PUYAML1_64" returned
message "the driver cound't identify inserted rows". Msg 7343, Level
16, State 2, Line 75 The OLE DB provider "MSDASQL" for linked server
"DDL_PUYAML1_64" could not INSERT INTO table "[MSDASQL]".
I have tried with Single Value but nothing changes.
As suggested Error messages when you perform an UPDATE, INSERT, or DELETE Transact-SQL statement on a remote table by using the OpenQuery function: "7357" and "7320" here, I have tried with column names instead of "*" and tried putting where 1=0 as well.
Any suggestion/feedback is appreciated.
Thank you!
EDIT: PFB the code
Insert openquery([DDL_PUYAML1_64],'select sn1,encl,encl_model from ws_sls_core.dd_enclosures_forarsdashboard_v1 where 1=0 ')
select sn1,encl,encl_model from #temp1

Find Column Data type in linked server

I just started working on a new project where data is stored in linked server. I have to add new columns to a table in staging environment, which already exists under same table name in linked server.
I have dumped data into a temp table but all the columns with data type decimals, int and numerics are converted into float in staging database. Also, when I'm trying to access information_schema or sys.columns for metadata getting below error. Any workaround to see the data type of table columns in linked server ?
select * from openquery(LINKEDSERVER,'select * from information_schema.columns')
Error:
OLE DB provider "MSDASQL" for linked server "LINKEDSERVER" returned message "[LINKEDSERVER][ODBC 64bit driver][OpenAccess SDK SQL Engine]Base table:columns not found.[10129]".
Msg 7321, Level 16, State 2, Line 45
An error occurred while preparing the query "select * from information_schema.columns" for execution against OLE DB provider "MSDASQL" for linked server "LINKEDSERVER".
Thanks in advance.
If you can query the linked server, then the following would work:
select
*
from [LinkedServerInstanceHere].[DatabaseOnLinkedServerHere].information_schema.columns
Just populate your details in [ ]...
I just tested it and it works on my side.
Hope this helps.

SSIS OLE DB Destination Table View Fastload or normal does not give error on duplicate key

I am filling a table using a package and after preparing the data to be saved I present it to an OLEDB destination for SQL server and setting the data acces mode to Table or View - Fastload or just Table or view (no fast load).
There is no error message but it does not write to the table.
I switch over to the normal Table or View so that each record is inserted with a separate INSERT command instead of a BULK insert.
When nothing happens I stop the execution of the package and do a select * from the destination table. I saw that he inserted 20 records. After investigation the data which is send to the OLE DB destination, I saw that record 21 results in a duplicate key.
Instead of getting an error message the package does not continue its execution flow.
What am I doing wrong.
Go through all the elements of the package, including the package itself, and set:
FailPackageOnFailure = True

How to add null value if a column doesn't exist

I have a package in my ETL that loops through 4 different databases, each with a copy of the same table. I found out that one of the four tables has one extra column named MTFvalue_Permit thus giving me the below error. My fact and staging tables, however, do include this column.
I was hoping ssis would just insert a null value if the column didn't exist. How can I add a null value into my Data Warehouse tables for the other three tables in which this column doesn't exist?
Error:
[Source DB IBS [1]] Error: SSIS Error Code DTS_E_OLEDBERROR. An OLE DB error has occurred. Error code: 0x80040E14.
An OLE DB record is available. Source: "Microsoft SQL Server Native Client 10.0" Hresult: 0x80040E14 Description: "Statement(s) could not be prepared.".
An OLE DB record is available. Source: "Microsoft SQL Server Native Client 10.0" Hresult: 0x80040E14 Description: "Invalid column name 'MTFvalue_Permit'.".
Edit: I'm thinking about using a case statement like this for the query but I'm getting a different error.
SELECT
[blahblahblah] ,
[blahblahblah] ,
[blahblahblah] ,
[blahblahblah] ,
[blahblahblah] ,
CASE WHEN COL_LENGTH('wmManifests', 'MTFvalue_Permit') IS NOT NULL
THEN [MTFvalue_Permit]
ELSE NULL
END AS 'MTFvalue_Permit'
FROM dbo.wmManifests
Invalid column name 'MTFvalue_Permit'.
I don't think that you can do it using expressions.
You can do this workaround.
Add a Script task that list columns from the table
Build the Select query dynamically:
If the column is not found pass NULL instead of the column name and give an alias (same as column name)
save this query string into a SSIS variable and use it as a source
You can also create a stored procedure that generate the query string. Execute it from a sql task and store the query string into ssis variable
Perhaps I am not understanding your question, but it seams like you are approaching this problem backwards. You cannot insert data into columns that do not exist. Is there a reason this column exists in only one out of four versions of this table? And does this column have a default value that you can leverage?
I would continue inserting to the set of columns that are common among all tables and allow the tables with columns that do not exist in every one of the tables in the set to use the default value for that column.

SSIS: Convert between Unicode and Non-Unicode Strings

Setup
I have a data flow task with:
An OLE DB Source selecting all data from a database table (SQL Native)
An OLE DB Destination of an Access 2003 File template (MS Jet 4.0)
So Essentially I am selecting a table and inserting it into a .mdb file.
Problem
I have the error:
column [X] cannot convert between unicode and non-unicode string data types
However If I add a 'Data Conversion Step' to convert all columns of type DT_STR to DT_WSTR, that error message goes away however I get the error message:
[DTS.Pipeline] Error: "component "OLE DB Source" (6289)" failed validation and returned validation status "VS_NEEDSNEWMETADATA".
Iv'e been Googling this problem for a while and still can't fix it.
Any ideas?
Instead of
Select * from tblName
use
Select col1, col2, col3, etc from tblName
The reason I found is, when you use different database, they might have one or two column that cause issue as it's not mapped. So when you use table query, be specific regarding column name.

Resources