SSIS Dynamically Import Excel Files - excel

So I created a ForEach loop and a data flow task to write from Excel to SQL DB. All works fine with the Excel source hard coded. As soon as I change the connection string to use the file path variable as a data source, I get this error:
[Excel Source 1] Error: SSIS Error Code DTS_E_CANNOTACQUIRECONNECTIONFROMCONNECTIONMANAGER. The AcquireConnection method call to the connection manager "Excel Connection Manager 1" failed with error code 0xC0202009.
I print the file path in a message box before executing the data flow so I know that the variable is working.
Naturally I browsed tons of answers and tutorials, but nothing. Here's what I tried:
Changing the data source on the connection string
Using the ExcelFilePath expression instead of the connection string
Changing the Excel file name in the connection manager properties
Ran the package in 32 bits
Set delayed validation to True in all data flow tasks and connection manager
Deleting and creating a new connection manager
Combinations of the above, lots of trial an error
I'm using Visual Studio 2013.
I'd appreciate your help as I've been plucking my hair all afternoon with this :)

I never got this to work, so I imported the Excel files to the DB using SQL:
SELECT * FROM OPENROWSET('Microsoft.ACE.OLEDB.12.0', 'Excel 12.0;Database=C:\Test\Excel_Data.xlsx;', 'SELECT * FROM [Sheet1$]')
https://www.sqlshack.com/query-excel-data-using-sql-server-linked-servers/

Related

Issues Displaying SSIS Data - Importing from Excel File to SQL DB

I am importing data from an Excel file into a SQL DB but it keeps giving me errors. I receive the error listed below for all of my control flows and there are five. How can I resolve this error?
Data viewer at path 'Excel Source Output' of task 'Data Flow Task - Course Facts' [DataflowID: {DF84ABE7-A1C5-4CA8-B5B9-C4FED8744F8E}; IDString: Paths[Excel Source.Excel Source Output]; PackageRPath: Integration Services Project1\Package.dtsx];;;break always (currently 0)
event log

Package executed in Visual Studio cancels without helpful error

I am following a Udemy Course Learn ETL using SSIS. The first simple task is to transfer data from an excel file to a database.
The only change I have made is I am trying to transfer to a PostgreSQL server instead of a Microsoft SQL Server. I therefore had to install SSDT for Visual Studio first, and get the ODBC driver necessary to create a ODBC Destination for the package.
All well so far, but then when I try and run the package I just get:
SSIS package "Visual Studio 2017\Projects\Excel_SQL\Excel_SQL\Package.dtsx" starting.
Information: 0x4004300A at Excel to SQL, SSIS.Pipeline: Validation phase is beginning.
Information: 0x4004300A at Excel to SQL, SSIS.Pipeline: Validation phase is beginning.
Information: 0x40043006 at Excel to SQL, SSIS.Pipeline: Prepare for Execute phase is beginning.
Information: 0x40043007 at Excel to SQL, SSIS.Pipeline: Pre-Execute phase is beginning.
Information: 0x4004300C at Excel to SQL, SSIS.Pipeline: Execute phase is beginning.
SSIS package "Visual Studio 2017\Projects\Excel_SQL\Excel_SQL\Package.dtsx" finished: Canceled.
The program '[14368] DtsDebugHost.exe: DTS' has exited with code 0 (0x0).
No data transfers over. The excel file is very simple, excel 97-2003 as the connection expects, contains 2 columns only, rollnumber and marks, rollnumber has 11 rows of data going 1 to 11, and then some random marks in the marks column.
My database on Postgres is set up with these 2 columns, as numeric types.
I really cannot figure out what is going wrong.
I have seen some similar questions on stack overflow, but that was around the file type not being correct:
SSIS Package Cancels instantly on Debug
I don't think that's my issue.
Can anyone please advise?
Thank you.
I think the situation is not clear, but there are many suggestions that you can follow:
(1) Try to run the package in 32-bit
The issue may be caused if the package is trying to run in 64-bit mode and you don't have installed the relevant references, try to execute the package in 32-bit mode:
Package Properties >> Debugging >> Run64BitRuntime = false
How to execute a 32 bit SSIS package in a 64bit package?
(2) AccessDatabaseEngine is not installed
The issue may be caused if the Office connectivity components for microsoft Excel are missing, check that you have installed them:
Microsoft Access Database Engine 2010 Redistributable
Microsoft Access Database Engine 2016 Redistributable
(3) Make sure you have followed the appropriate steps to create ODBC Destination
You can follow this article in order to create a package that import data to postgres, check that all steps are done correctly:
SSIS WITH POSTGRESQL : CONNECT TO POSTGRESQL WITH SSIS COMPONENTS
(4) Doing some workarounds
In order to specify the error source, try to replace the Postgres destination with a Flat File Destination, if the package is executed successfully then the problem is with the ODBC Destination, also try to replace the excel source with FLat File Source, if the package is executed successfully then the problem is with the Excel Source.
If you are new to SSIS, som articles can help:
Simple SSIS: Importing Data from Flat Text Files
Export Data from SQL Server to Flat File in SSIS Example
Using SSIS to Export Data to Flat Files
(5) Try to Use SQL Import Export Wizard
If you have SQL Server Installed, try to use the Excel Import Export wizard to create and execute the package:
Import and Export Data with the SQL Server Import and Export Wizard
Connect to a PostgreSQL Data Source (SQL Server Import and Export Wizard)
How to export data from SQL Server to a Flat file
So, in this case it was that I just had to move the (Source) excel file out to my E:\ drive. Perhaps the path it was in was too long? Only 3 folders in from E:\ but...it worked.
Can anyone explain why that was the issue? Nothing pointed to that from the error messages.

An error occurred saving import/export specification ''

I am new to MS-Access.
The title is the error I get when I try to import an excel sheet into a new table in Access 2016. Note the single empty quote is part of the error message.
I've tried reinstalling, playing around with import options, importing from a CSV, CSV with different encodings, checked the table in excel for errors or inconsistencies.
I have searched and searched without luck. Help would be appreciated.
ADDENDUM:
The CSV I've tried to import is:
CashAccountID,AccountDescription,BankName,BankAccountNumber
301,Primary Checking Account,MegaBank,9017765453
302,Money Market Account,Wells Gargle,3831157490
303,Payroll Account,MegaBank,9835320050
I've encountered the same error and, from trial and error, it appears the issue is related to the size of the Excel file you're importing from. I've had success by splitting the 70MB Excel file into two 35MB files before doing the same import into Excel.
The error message from MS Access is nonsensical - the problem occurs when we're not using an import/export specification at all (and nor are there any saved in the Access I'm running). I think we can put this failure and erroneous error message down as an MS Access bug.

Error when trying to import excel data to SQL Server 2008

I have an excel file that has data. The first row has the columns. I am trying throw SSIS to import these data on a database. On the edit mappings I am setting the destination columns “Nvarchar (max) “ . All the columns are imported successfully on Sql server but one column produce the bellow error. I have try to edit the “HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Jet\4.0\Engines\Excel” registry key from 8 to 64 but I still taking the same error. I have follow also the instructions from this post Text was truncated or one or more characters had no match in the target code page When importing from Excel file
with no luck.
The error that I am taking:
"Executing (Error)
Messages
Error 0xc020901c: Data Flow Task 1: There was an error with output column "MyColumn,M" (63) on output "Excel Source Output" (9). The column status returned was: "Text was truncated or one or more characters had no match in the target code page.".
(SQL Server Import and Export Wizard)
Error 0xc020902a: Data Flow Task 1: The "output column "MyColumn,M" (63)" failed because truncation occurred, and the truncation row disposition on "output column "MyColumn,M" (63)" specifies failure on truncation. A truncation error occurred on the specified object of the specified component.
(SQL Server Import and Export Wizard)
Error 0xc0047038: Data Flow Task 1: SSIS Error Code DTS_E_PRIMEOUTPUTFAILED. The PrimeOutput method on component "Source - Page1$" (1) returned error code 0xC020902A. The component returned a failure code when the pipeline engine called PrimeOutput(). The meaning of the failure code is defined by the component, but the error is fatal and the pipeline stopped executing. There may be error messages posted before this with more information about the failure.
(SQL Server Import and Export Wizard)
"

Load excel file that changes name with SSIS

So I have a folder in which excel files get loaded daily. I need to create a package that extract those files to a sql table. However, the file changes name daily as the name comes with the current date,so the filename would be like filename+currentdate(name20140801.xlsx).
I tried using a variable that has filename?.xlsx/filename?*xlsx as a excelpath property for the excel connection manager but the task gives me an error DTS_E_CANNOTACQUIRECONNECTIONFROMCONNECTIONMANAGER.
Does anyone know how i can do this using the Data Flow task( I am trying to avoid Script task)
Thank you!

Resources