SSIS package is executing while modification done on source table - sql-server

i created a SSIS package using simple DFT and transferring files from OLEDB source to OLEDB destination. When i am adding new column in my source table package is still getting executed successfully but i want my package to get failed. Could anyone suggest how to fix it.

In the Control Flow area, add an Execute SQL Task before your DFT.
Set up the connection to your database and for your SQLStatement use the following:
CREATE TABLE #temp (<define all columns currently in your OLEDB Source Table>)
INSERT INTO #temp
SELECT TOP 1 *
FROM <your OLEDB Source Table>
By using this "worst practice" insert syntax, you can cause a failure if your OLEDB Source Table has any columns added or removed.

When selecting a Table in OLEDB Source, the metadata of the table is mapped to the OLEDB Source component.
Each time you will run the package it will sends a SELECT * From Table command to the SQL server, and retrieve the data and it will map every column from the SQL table to the OLEDB Source column.
If a column is found in SQL and it is not defined in OLEDB Source it will be ignored. In the other hand, if a column is not found in SQL and it is defined in OLEDB Source it will throw an exception.
The only way to validate metadata before running the package is to add an Execute SQL Task or Script Task to check the metadata before the DFT is executed.
References
SSIS OLE DB Source Editor Data Access Mode: “SQL command” vs “Table or view”
OLEDB Source

Related

SSMS - Running SSIS package via batch file - resulting table empty

Currently I am building a database in SQL Server Management Studio (SSMS). Several data sources are imported in this database, via the import/export wizard. Upon completion of the import, not only am I running the import, I also save an SSIS package. This SSIS package is to schedule a weekly refresh of the data source.
On my Windows Server 2012 R2 the Express edition is installed, therefore I have manually created several batch files that run every week (as scheduled via Task Scheduler). This works fine for most tables, however for some tables I encounter some strange (?) behaviour.
This is as follows: when creating the SSIS package via import/export wizard, and directly running the import, the table shows up correctly in the database. That is, with all column names and the thousands of rows it contains.
The strange thing is that, when executing the SSIS package (via the batch file), the table is empty (column names are correct though). For some tables, I do not encounter this behaviour. For others, this behaviour is encountered all the time.
The batch script is as follows (quite straightforward):
"C:\Program Files (x86)\Microsoft SQL Server\140\DTS\Binn\DTExec.exe" /F "C:\Users\username\ssispackage.dtsx"
The batch file seems to run correctly at all times, as the table 'creation_date' changes when I run the batch file. Moreover, for all the tables that do correctly 'refresh', these same batch files do the job.
Some settings of the SSIS package:
Data source: Oracle OLE DB provider
Destination: SQL Server Native Client / MS OLE DB Provider for SQL Server (tried both)
Data via query (as I am querying several tables from Oracle); query is parsing correctly
Mappings: Create destination table & Drop and re-create destination table
Dropping and re-creating is done, because the data source is rather small, and has some changes weekly/monthly (to some rows).
For most data sources imported (and refreshed weekly) via this method, the tables are correctly showing each week (simply dropping the previous table, and re-creating the source).
I hope someone can explain to me why this issue occurs. If some more information is needed from my side, please ask.
Thanks in advance!
UPDATE:
When looking at the log of the batch file, this is (part) of the output:
Source: ..... "SourceConnectionOLEDB"
Description: SSIS Error Code DTS_E_OLEDBERROR. An OLE DB error has occurred. Error code: 0x80004005.
An OLE DB record is available. Source: "OraOLEDB" Hresult: 0x80004005 Description: **"ORA-01005: null password given; logon denied".**
End Error
.....next error.... "SSIS Error Code DTS_E_CANNOTACQUIRECONNECTIONFROMCONNECTIONMANAGER.
Thus, it seems that the password is not remembered/saved correctly in the SSIS package?
This is strange though, as for most tables it does correctly store the password (as those do refresh correctly).
When setting the properties of the data source, namely Oracle Provider for OLE DB, I select the option "Allow saving password". So it should store the password correctly?
Found the answer after all.. The .dtsx file that is saved (the SSIS package) contains the variables for the connection string, it shows that the Password (Sensitive="1") is there. But in the wizard, I did not select 'Save sensitive data with user key'. When selecting this option, an encryption string was added. Now the SSIS packages run well!

SSIS Access Database - Need to empty table on my destination Access Database table before inserting new records

Task:
Transfer data from SQL Server into Access Database
Issue:
How to empty my Access destination table before I run the data flow?
I tried to use an Execute SQL Task to run a TRUNCATE command similar to SQL Server, but it seems not working with Access Database?
Thanks in advance!
You can use Execute SQL Task to query a Microsoft Access Database, but you cannot use a Truncate command since it is not supported, you have to use a DELETE FROM ... command.
The following screenshots show an example of the OLE DB Connection manager, and the Execute SQL Task configuration:

SSIS package validation error - flat file destination has no ID

i have a OLE DB SQL Command with a flat file destination and have added to column headers to the flat file but when executing package I get the below issue. is this because I have 2 extra columns in flat file?
Sounds like your package got corrupted. Your best bet is to drop and re-create the flat-file Destination Connection Manager, and then re-add the connection to the Destination.

SSIS - How to insert into OLE DB destination using SQL command while the source is flat file?

I want to know how to insert value in SQL Server database with the flat file source in SSIS using SQL command. I've done inserting it using table view, now i have to insert it using SQL command
Well you need a good query to set into a Execute SQL Task in SSIS
you can get help for queries in the site below
----here is the link ----
well you can parametrize the query in Execute SQl Task of SSIS
BCP
This is one of the options that is mostly widely used. One reason for this is that it has been around for awhile, so DBAs have come quite familiar with this command. This command allows you to both import and export data, but is primarily used for text data formats. In addition, this command is generally run from a Windows command prompt, but could also be called from a stored procedure by using xp_cmdshell or called from a SSIS package.
Here is a simple command for importing data from file C:\ImportData.txt into table dbo.ImportTest.
bcp dbo.ImportTest in 'C:\ImportData.txt' -T -SserverName\instanceName
BULK INSERT
This command is a T-SQL command that allows you to import data directly from within SQL Server by using T-SQL. This command imports data from file C:\ImportData.txt into table dbo.ImportTest.
BULK INSERT dbo.ImportTest
FROM 'C:\ImportData.txt'
WITH ( FIELDTERMINATOR =',', FIRSTROW = 2 )
Forgot to say that u can write a select query too with the samples in a OLEDB Source Using Sql Command

Copying data from one database to another using SSIS

I am writing a SSIS package and trying to extract the data from one database to another. I have created a Execute SQL task and using the following statement INSERT INTO dbo.getParties EXEC dbo.getParties to perform the operation. This works when the source and destination our in the same database. How do I handle this when the source and destination are in different databases. You can associate only one connection manager to a task.
Do I connect to the source and in the SP call the destination. Is it the right way of doing it
Below is the design of my template
Use Data Flow component where you can set up the source and destination connection strings.
..and inside the data flow task use the Destination and Source Assistants that let you define its own connection string for each.
Of course, besides these you can also apply any sort of data transformations you wish.
Edit:
Since you your source is SQL Command (stored procedure) you need to define it in your source assistant. As you can see here, just change Data Access Mode to SQL Command and set to EXEC getParties:
In the Execute SQL Task INSERT INTO Command just add the Database name to the Table name. ex:
INSERT INTO Db1.dbo.Table1
SELECT * FROM Db2.dbo.Table2
Side Note: i think that it is better to use DataFlow Tasks to copy data, because it is faster and provides more controls and error handling

Resources