SQL Server Integration Services - sql-server-2008

I am using SSIS to import an Excel file into a table in my SQL Server 2008 database.
Currently I am able to import data into the table by using data flow setting Excel file as the source and data table as the destination. My current import is based on the column mapping between source and the destination, but now I want to add an extra column to the table (basically this column will have the id that is given to the Excel file of which the rows are part of, so this value will be same for each row that belongs to the file whose data we are currently importing)
This column is not present in the source Excel sheet and its value is in a SSIS user variable. I want the insertion of this value a part of the import process, but I cannot figure it out?
How can I achieve this?
The connection manager for the destination doesn't allow me to map user variables to columns...

Put in a Derived column between the Excel Source and the Database destination.
Create a column there and use the SSIS User Variable as the value expression for the column.

Add a execute SQL task after the dataflow task and update the extra column with the variable with an update statement.

Related

Add VBA code in order to amend Excel output in SSIS before sending to Excel destination?

I have a current package which basically copies an Excel template sheet, writes data into this from a table in the SQL database and then sends to Excel destination (ishare drive and server drives). We have repeated rows with specific data which need to be removed from the Excel sheet before it is sent out. We have a VBA code which can be run in Excel as a macro in order to achieve this result. I am wondering how I can automate this in SSIS in the data flow?
I have a current package which basically copies a an excel template
sheet, writes data into this from a table in the sql db
You can use a Data Flow Task where you import data from the SQL Server database:
Create a connection manager :
When you click on the New Connection Manager option, an Add SSIS Connection Manager window form will open to select the connections managers from the given list.
Then select the Provider, Server Name, and Database Name (you will point to a SQL Server database you can either select the table or use a query)
If you want to remove duplicate entries you can use Drag Transformation and Connect your OLE DB Source to it. Double Click on Sort Transformation and Choose the columns to Sort. Also Check the Check Box : Remove rows with duplicate sort values and then click OK.
If you have other specific rules, you can implement a T-SQL query when importing data from the begining (when using the OLE DB Source)
Then you can link it to an Excel destination.

how to consider 2 row as column names for importing excels to sql server using SSIS

I am importing Excel data to DB using SSIS package.
The problem is i want to consider second Row i.e A2:Z2 as column name.
I don't want to take A1:Z1 into consideration.
How can i achieve it.
My researched Link 1 Link 2
I have a sample excel file with the data like
In excel source use SQL Command for Data access mode and write the query to skip the initial row
SELECT * FROM [Sheet1$A2:B]
--In your case it will be [Sheet1$A2:Z]
and in the excel connection manager select the option First Rows as Column name
When i try to preview it ,i get the data from the 2nd row onwards

add parameter value to table at import SSIS

I am importing an Excel table from an ftp site to SQL using SSIS. The destination table is going to be used to calculate good and bad records based on another SQL database. Here is my problem. The Excel file is name RTW_032613_ABC_123.xls. This file name is a concatenation of a number of fields. I cannot recreate it based on the fields in the table, so I need to retain it and pass it to the new table in SQL. I have a parameter #FileName that I am using to loop through the files in the ftp folder. What I would like to do is either combine the import of data from the Excel file with the file name or insert the file name in each record after the import. I am calling the SSIS procedure from another stored procedure in SQL. I tried adding a SQL data flow task but I am not seeing where I add the insert statement on either the SQL Server Compact Destination or SQL Server Destination.
I am over my head with SSIS on this one. The key is that the parameter that I need is available in SSIS but I really need to get it passed on to my SQL table.
TIA
If I'm reading your question right, you have an SSIS package with a variable containing the filename and you want to save the filename with each row that you are sending to your SQL table? If so:
Add a derived column to the data flow, making a new column and referencing the variable in the expression
Include that new column in the mapping for the destination of your data flow, sending the filename to whichever column you would like to save that data in.
No need for a seperate SQL task.

Dynamically mapping columns from source to destination

I am creating an SSIS package which has a flat file source and a destination database.
The mappings between the columns are based on the following:
There is a table which contains records indicating the mappings ie: source column name and destination column name. The tables will be based on the name of the flat file.
The reason this has been done is so that the destination column names can be changed in the database rather than needing to recreate or edit the package.
Please could you advise as to how I could do this "lookup" and create the mappings dynamically.
There is no way to create mappings dynamically. You'll need to either generate SSIS package programmatically on the fly, or use other method (openrowset, bcp, bulk insert...).

Excel SSIS and SQL server

I want to develop an automation in SSIS.
Problem statement :
I have an excel sheet which has a single column.
Based on the values in that column (will be included as a search parameter in the SQL query) I need to fetch 2 or more columns from SQL server database
The results are to be stored in the same Excel sheet against the data obtained for that particular column.
I already have an excel macro for the same. But, now I want to develop a package for the same.
Please guide me through the necessary steps.
I will also keep trying to obtain the solution
Create an Excel Source and link it to your file
use a lookup component to perform a SQL select to obtain the missing data
Create an Excel destination to save your target data