Issue with accessing a file after renaming it - sql-server

Step1: I have a script task at first to get excel file at a specific location and delete few lines of data and then rename the file to "Report.xlsx" the same location.
Step2: Now I have a Data Flow task, I have used an Excel Source to load rename excel file by specifying the "FilePath+Report.xlsx" in the Excel File Path of Excel Connection Manager and selected the Sheet1$ as Name of the Excel sheet.
My Goal is to get the file in that location => rename the file to "Report.xlsx" => then load the data from excel to table.
But when I run the report, I am getting the below error
Error at Work_Data [Excel Source [2]]: SSIS Error Code DTS_E_OLEDBERROR. An OLE DB error has occurred. Error code: 0x80040E37.
Error at Work_Data [Excel Source [2]]: Opening a rowset for "Sheet1$" failed. Check that the object exists in the database.
Error at Work_Data [SSIS.Pipeline]: "Excel Source" failed validation and returned validation status "VS_ISBROKEN".
Error at Work_Data [SSIS.Pipeline]: One or more component failed validation.
Error at Work_Data: There were errors during task validation.
My guess is that, the Excel Connection Manager trying to access the Report.xlsx report which will not be there before renaming (I guess).
Is there a way to achieve my Goal ?

Related

Getting "External table is not in the expected format." error while trying to import an Excel File in SSIS

I am trying to import an Excel file (.xls) via SSIS to a table in SQL Server. But SSIS doesn't seem to recognize the file as a valid Excel file. I get the following errors:
Error 1:
[Excel Source [86]] Error: SSIS
Error Code DTS_E_CANNOTACQUIRECONNECTIONFROMCONNECTIONMANAGER.
The AcquireConnection method call to the connection manager "Carga Base Original" failed with error code 0xC0202009. There may be error messages posted before this with more information on why the AcquireConnection method call failed.
Error 2:
[SSIS.Pipeline]
Error: Excel Source failed validation and returned error code 0xC020801C.
Error 3:
[Connection manager "Carga Base Original"] Error: SSIS Error Code DTS_E_OLEDBERROR. An OLE DB error has occurred. Error code: 0x80004005.
An OLE DB record is available.
Source: "Microsoft Access Database Engine"
Hresult: 0x80004005
Description: "External table is not in the expected format".
My connection manager properties is an Excel Source, its properties look like this:
I am passing the Excel file path through a variable. The Excel file looks OK and is not corrupted. I tried to put a fix Excel path, try to put it in Connection String property (fix path and variable), but nothing of this helped.
Can anyone please help me?
The main error is:
External table is not in the expected format
This happens when the Excel file is corrupted and cannot be opened by Access Database Engine (OLE DB provider) even if you can open the file from Excel. In a similar case opening the file manually and saving it as a new file may do the trick.
In my case saving the mail-merged reference Excel file as .xls (Excel 97 - 2003) worked. .xlsx provoked the "External table is not in expected format" error message but .xls did not.

Convert Excel File to CSV Then Load to SQL Table Using SSIS

I have a very large excel data to load to SQL table. For small data it works. However, for large data (more than 20 million records) I get the following error.
Excel to CSV : There were errors during task validation. Excel to CSV
Error: "Excel Source" failed validation and returned validation status
and returned validation status "VS_ISBROKEN". Excel to CSV: opening a
rowset for "Table1$" failed. check that the object exists in the
database. Excel to CSV:Error : SSIS Error code DTS_E_OLEDBERROR. An
OLE DB error has occurred .Error code 0x80004005.
My package had no problem. The issue is with the excel file . For small data the extension .xlsx works ( excel 2007) . For the large data i have to convert the data to Excel 97 version which is (.xls). Doing so help load the data
Usually when I get this error, something is wrong with the destination table. Check the existence of the table and also match of fields between source and destination.

Issues Looping through Excel Files in SSIS 2012 (Foreach ETL)

I am trying to process Excel files (2007 .XLSX) in a directory on the local machine. There have been a number of issues that have come up of which I will list. Before that let me explain what I want to do and how I have set things up and all my attempts so far.
Set Up
Microsoft Visual Studio 2012
Microsoft Windows 7 (32 bit)
Goal
Create a simple ETL to loop through Excel files in a folder and load data into a SQL server table.
Current Attempts
Note: I am very much familiar with programming and especially loops, however in SSIS I am struggling to get the Excel file from even being read.
I have tried and am doing the following:
Created a package
Created a FOREACH loop container task
FOREACH Loop Task
Set as Foreach File Enumerator
Expression assigns the Directory to the variable which has the value of the directory ('C:\Users\Me\Desktop\Excels\')
Under Variable Mappings I have specified a variable at index 0
Set to using File and Extension
For the moment I am looking at all files (.)
Note: I have used watch on debug to determine if the variables get populated. Now I have tried an expression task to build the full path before moving onto the data flow as well as just using the two variables assigned.
Data Flow (after FOREACH loop container)
Set up Excel File Source
Set up OLE DB Destination
Excel Source (inside Data Flow as the first task)
Set up the columns initially using one of the files (preview and input/output's are shown)
Note: Data is shown so the connection seems fine
Excel Source Connection Manager
DELAY VALIDATION = TRUE
EXPRESSIONS = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + #[User::excelFullPath] + "Extended Properties='EXCEL 12.0 XML;HDR=YES';"
ExcelFilePath = #[User::excelFullPath]
FirstRowHasColumnName = TRUE
Note: I have tried a combination of using the connection string and the excel file path property. I have tried those on their own.
Note: I have two Excel files in the folder for the moment. They are identical with different file names and YES the columns are the same.
Errors Received
The latest error upon RUN is:
SSIS package "C:\Users\biadmin\Desktop\0006AssocImport\0006AssocImport\Package.dtsx" starting.
Information: 0x4004300A at Data Flow Task, SSIS.Pipeline: Validation phase is beginning.
Error: 0xC0202009 at Data Flow Task, Excel Source 1 [2]: SSIS Error Code DTS_E_OLEDBERROR. An OLE DB error has occurred. Error code: 0x80040E37.
Error: 0xC02020E8 at Data Flow Task, Excel Source 1 [2]: Opening a rowset for "MAIN$" failed. Check that the object exists in the database.
Error: 0xC004706B at Data Flow Task, SSIS.Pipeline: "Excel Source 1" failed validation and returned validation status "VS_ISBROKEN".
Error: 0xC004700C at Data Flow Task, SSIS.Pipeline: One or more component failed validation.
Error: 0xC0024107 at Data Flow Task: There were errors during task validation.
Warning: 0x80019002 at Foreach Loop Container: SSIS Warning Code DTS_W_MAXIMUMERRORCOUNTREACHED. The Execution method succeeded, but the number of errors raised (6) reached the maximum allowed (1); resulting in failure. This occurs when the number of errors reaches the number specified in MaximumErrorCount. Change the MaximumErrorCount or fix the errors.
Warning: 0x80019002 at Package: SSIS Warning Code DTS_W_MAXIMUMERRORCOUNTREACHED. The Execution method succeeded, but the number of errors raised (6) reached the maximum allowed (1); resulting in failure. This occurs when the number of errors reaches the number specified in MaximumErrorCount. Change the MaximumErrorCount or fix the errors.
SSIS package "C:\Users\biadmin\Desktop\0006AssocImport\0006AssocImport\Package.dtsx" finished: Failure.
The program '[6272] DtsDebugHost.exe: DTS' has exited with code 0 (0x0).
Another Error Received Earlier
SSIS package "C:\Users\biadmin\Desktop\0006AssocImport\0006AssocImport\Package.dtsx" starting.
Information: 0x4004300A at Import RAW Excel Data, SSIS.Pipeline: Validation phase is beginning.
Error: 0xC0202009 at Package, Connection manager "Excel Connection Manager": SSIS Error Code DTS_E_OLEDBERROR. An OLE DB error has occurred. Error code: 0x80004005.
An OLE DB record is available. Source: "Microsoft Access Database Engine" Hresult: 0x80004005 Description: "Could not find installable ISAM.".
Error: 0xC020801C at Import RAW Excel Data, Excel Source [2]: SSIS Error Code DTS_E_CANNOTACQUIRECONNECTIONFROMCONNECTIONMANAGER. The AcquireConnection method call to the connection manager "Excel Connection Manager" failed with error code 0xC0202009. There may be error messages posted before this with more information on why the AcquireConnection method call failed.
Error: 0xC0047017 at Import RAW Excel Data, SSIS.Pipeline: Excel Source failed validation and returned error code 0xC020801C.
Error: 0xC004700C at Import RAW Excel Data, SSIS.Pipeline: One or more component failed validation.
Error: 0xC0024107 at Import RAW Excel Data: There were errors during task validation.
Warning: 0x80019002 at Foreach Loop Container: SSIS Warning Code DTS_W_MAXIMUMERRORCOUNTREACHED. The Execution method succeeded, but the number of errors raised (5) reached the maximum allowed (1); resulting in failure. This occurs when the number of errors reaches the number specified in MaximumErrorCount. Change the MaximumErrorCount or fix the errors.
Warning: 0x80019002 at Package: SSIS Warning Code DTS_W_MAXIMUMERRORCOUNTREACHED. The Execution method succeeded, but the number of errors raised (5) reached the maximum allowed (1); resulting in failure. This occurs when the number of errors reaches the number specified in MaximumErrorCount. Change the MaximumErrorCount or fix the errors.
SSIS package "C:\Users\biadmin\Desktop\0006AssocImport\0006AssocImport\Package.dtsx" finished: Failure.
These are not all the errors received (I did not record all of them) but at the moment its just failing on one particular error at a time.
Note
I have seen quite a few YouTube tutorials and read a few outlining the exact steps. I have seen one where they set the connection manager from a Script task before getting to the Data Flow task. I saw one where the ConnectionString property was set only to the variable that holds the Excel File Path.
Questions
What am I missing in my set up
After configuring the connection manager to look at a variable for the file is there anyway of still configuring inputs and outputs on the Excel Source task because at the moment its showing an error
What is the developer preference in SSIS for this sort of situation where I prefer to see the column mappings on the configuration box (Script or Flow)

How to import local flat tab file into new table within database using SQL Server 2012?

How do I import a local flat tab file into a database using SQL Server 2012 without truncation errors?
What I have tried: To import the local flat tab file into my database. I'm using Microsoft Sql Server Management System (MS SMS). I receive errors that the FULL_DESCRIPTION column is truncated. I changed the data type for that column to max and tried VARCHAR(max) & NVARCAR(max) & NTEXT(max) but I receive the same errors. I right click on the database > Tasks > Import Data.
Then the SQL server Import and Export Wizard appears.[Choose From Data Source.] > [Choose Data Destination to copy to.] > [Table Preview] > [Review Data Mapping] > Finish. It starts executing and I receive the following error screen.
Error 0xc02020a1: Data Flow Task 1: Data conversion failed. The data conversion for column "FULL_DESCRIPTION" returned status value 4 and status text "Text was truncated or one or more characters had no match in the target code page."
Error 0xc020902a: Data Flow Task 1: The "Source - NameOfTabularFlatFile.Outputs[Flat File Source Output].Columns[FULL_DESCRIPTION]" failed because truncation occurred, and the truncation row disposition on "Source - NameOfTabularFlatFile.Outputs[Flat File Source Output].Columns[FULL_DESCRIPTION]" specifies failure on truncation. A truncation error occurred on the specified object of the specified component.
Error 0xc0202092: Data Flow Task 1: An error occurred while processing file "C:\Users...\Desktop\NameOfTabularFlatFile" on data row 2.
Error 0xc0047038: Data Flow Task 1: SSIS Error Code DTS_E_PRIMEOUTPUTFAILED. The PrimeOutput method on Source - NameOfTabularFlatFile returned error code 0xC0202092. 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.
Here is the execution error.
What I researched. https://learn.microsoft.com/en-us/sql/integration-services/import-export-data/connect-to-a-flat-file-data-source-sql-server-import-and-export-wizard
I ended up transferring the flat file into an Excel file and importing it into the SSIS 2008 R2 database without loosing data.
I transferred the flat file into excel as Microsoft Excel 97-2003 Worksheet.
How to import an Excel file into SQL Server?

Package Validation Error

I'm trying to use a foreach loop container to import several excel files into a table, I specified the folder and the files I'm going to use (*.xls), after that I created a path variable then I went to the excel source connection and in the "Expression" property I selected the variable. I created the foreach container but, the excel source's connectionString only shows Provider=Microsoft.Jet.OLEDB.4.0;, so it means it's not taking the variable value. What can I do to solve that?
Note: I'm using SQL Server 2012
ADDITIONAL INFORMATION:
Error at Data Flow Task [Excel Source [20]]: SSIS Error Code DTS_E_CANNOTACQUIRECONNECTIONFROMCONNECTIONMANAGER. The AcquireConnection method call to the connection manager "Excel Connection Manager" failed with error code 0xC0202009. There may be error messages posted before this with more information on why the AcquireConnection method call failed.
Error at Data Flow Task [SSIS.Pipeline]: Excel Source failed validation and returned error code 0xC020801C.
Error at Data Flow Task [SSIS.Pipeline]: One or more component failed validation.
Error at Data Flow Task: There were errors during task validation.
Error at Package [Connection manager "Excel Connection Manager"]: SSIS Error Code DTS_E_OLEDBERROR. An OLE DB error has occurred. Error code: 0x80040E4D.
(Microsoft.DataTransformationServices.VsIntegration)
Check the link below where I answer mainly focus on RUN64BITS TO FALSE instead of TRUE.
Execel Source ERROR
Running a SQL 2012 SSIS Package via an MVC Website fails with:
The Script Task is corrupted.
and
There were errors during task validation.
Runs perfectly from with in BIDS.
To resolve it I set the Project Property:
Run64BitRunTime = False
Security = DontSaveSensitive
In the Package I set:
DelayValidation = True
Security = DontSaveSensitive
This still failed. I came across this which indicates that Script Tasks are the problem.
So I removed the script task and it worked straight away.

Resources