Using SSIS, how to insert new data from Excel sheet into my existing SQL Server table

SHAMIM

I have imported some data from Excel file into my SQL Server table using SSIS. As because it's a report of profit & loss statement it has a header named as Trading Name, address fiscal year etc.

In SSIS, I've used OLE DB Source and used the query like

Select * from [Sheet1$A10:E]

so the data has been picked up. But U need to insert the trading Name and fiscal year information along with the others data like

Trader FYear AccNo AccName   July        August     September
 a      2014 4-0000 In          
 a      2014 4-0500 Ad      $4,514.06   $4,521.23   $4,296.62
 a      2014 4-1000 Me      $37,085.78  $35,676.20  $36,150.87
 a      2014 4-1300 Ro      $11,876.20  $10,956.70  $11,819.04
 a      2014 4-2000 Gr      $57,540.76  $52,978.63  $54,272.24

I can pick up the trader and FYear from that Excel sheet by using OLE DB Source and SQL is

select * from [Sheet1$a1:a8]

and using conditional split I can separate them. But I don't actually know how to insert that data to each column of that table like above.

One more thing, if i write the query like

insert into tblA(Trader, FYear, AccNo, AccName, July, August, September)
   select 
      'a', '2014', tblB.AccNo, tblB.AccName, 
      tblB.July, tblB.August, tblB.September; 

then, it works in SQL Server table but could anyone help me to insert those two columns with that data like above table? Thanks anyway

![enter image description here][1]

Trading Name(a)                                                 
Address1                                                    
Address2                                                    


Profit & Loss Statement                                                 
Fiscal Year(2014)                                                   


AccNo    AccName               July       August    September
4-0000  In          
4-0500  Ad                    $4,514.06     $4,521.23   $4,296.62
4-1000  Me                    $37,085.78    $35,676.20  $36,150.87
4-1300  Ro                    $11,876.20    $10,956.70  $11,819.04
4-2000  Gr                    $57,540.76    $52,978.63  $54,272.24
4-3500  B                     $0.00         $0.00       $0.00
4-4000  P                     $3,576.76     $4,110.66   $2,208.31
4-5000  Be                    $19,559.94    $17,926.14  $18,260.71
4-6000  Tu                    $13,471.97    $15,042.04  $13,150.06
4-8900  Re                    $3,500.00     $0.00       $0.00
    Total Income              $151,125.47   $141,211.60 $140,157.85

5-0000  Cost of Sales           

    Gross Profit            $151,125.47 $141,211.60 $140,157.85

6-0000  Expenses            
6-1000  General & Administrative Exp            
6-1050  Accounting Fees            $0.00    $0.00   $270.00
6-1200  Bank Charges              $11.20    $11.20  $14.99
Nick.McDermaid

i can pick up the trader and FYear from that excel sheet by using OLE DB Source but i don't actually know how to insert that data to each column of that table like above

Use your existing method to populate two SSIS variables with the trader and FYYear at the start. Then subsequently in your data flow use a derived column transform and insert the variable value in as an additional column.

Based on the image you sent:

enter image description here

  1. Delete everything except the first ForEachLoop container and its contents

  2. Inside this ForEachLoop container add an execute SQL task which runs select * from [Sheet1$a1:a1]. This should get the Fiscal Year (if it's in that cell) and you should be able to load that result into a single string variable (which you need to create beforehand). You need to set it up as ResultSet=SingleRow and you need to map the resultset area. You do not need to use the parameter mapping area

See here more more info on how to load a variable from a single row result: https://www.simple-talk.com/sql/ssis/ssis-basics-using-the-execute-sql-task-to-generate-result-sets/

  1. Now in your existing Excel Data Source data flow, add a derived column transformation and include these string variables as extra columns that will be inserted into the table

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Insert data into columns of Excel sheet from SQL Server table

From Dev

How to create a new table from existing table with both keys and data in SQL Server 2012 (Management Studio)?

From Dev

How to insert/update rows from MySQL to SQL Server by using SSIS

From Dev

How to insert into an existing temp table in SQL Server

From Dev

How to insert into an existing temp table in SQL Server

From Dev

How can I export my python web scrape data to a specific sheet in an existing excel file using pandas?

From Java

How to save a new sheet in an existing excel file, using Pandas?

From Dev

How to save a new sheet in an existing excel file, using Pandas?

From Dev

Update SQL output data into Existing Excel in respective sheet using python

From Dev

SQL - INSERT new row by using sum of two existing rows from same table

From Dev

How to insert data to SQL Server table using R?

From Dev

Import Excel sheet data starting from specific row and columns to datagrid then into SQL Server table, WPF

From Dev

insert data in sql server from other table

From Dev

Insert data into table in SQL Server from XML

From Dev

Using query export SQL Server 2008 table to Excel Sheet

From Dev

SQL query to insert aggregated data into existing column using columns from same table

From Dev

Import image from Excel sheet into SQL Server table C#

From Dev

Exporting Data to Excel file From Sql Server 2014 using SSIS 2012

From Dev

How to find who deleted data from my table in sql server

From Dev

How to insert data from another table into an existing table, with an autoincrementing id?

From Dev

Excel How to import data from SQL Server using Transact SQL

From Dev

Excel How to import data from SQL Server using Transact SQL

From Dev

SQL Server, How to generate an `INSERT` statement for the rows in an existing table?

From Dev

How to Insert xml data into SQL Server table?

From Dev

Import Excel data into an existing SQL Server 2005 table

From Dev

how to copy only data from one database table to another database existing table in sql server

From Dev

How to copy Database from existing to new database sql script using sql server 2008 R2?

From Dev

SQL Insert data from 2 table to new table

From Dev

Import data to SQL Server table from Excel

Related Related

  1. 1

    Insert data into columns of Excel sheet from SQL Server table

  2. 2

    How to create a new table from existing table with both keys and data in SQL Server 2012 (Management Studio)?

  3. 3

    How to insert/update rows from MySQL to SQL Server by using SSIS

  4. 4

    How to insert into an existing temp table in SQL Server

  5. 5

    How to insert into an existing temp table in SQL Server

  6. 6

    How can I export my python web scrape data to a specific sheet in an existing excel file using pandas?

  7. 7

    How to save a new sheet in an existing excel file, using Pandas?

  8. 8

    How to save a new sheet in an existing excel file, using Pandas?

  9. 9

    Update SQL output data into Existing Excel in respective sheet using python

  10. 10

    SQL - INSERT new row by using sum of two existing rows from same table

  11. 11

    How to insert data to SQL Server table using R?

  12. 12

    Import Excel sheet data starting from specific row and columns to datagrid then into SQL Server table, WPF

  13. 13

    insert data in sql server from other table

  14. 14

    Insert data into table in SQL Server from XML

  15. 15

    Using query export SQL Server 2008 table to Excel Sheet

  16. 16

    SQL query to insert aggregated data into existing column using columns from same table

  17. 17

    Import image from Excel sheet into SQL Server table C#

  18. 18

    Exporting Data to Excel file From Sql Server 2014 using SSIS 2012

  19. 19

    How to find who deleted data from my table in sql server

  20. 20

    How to insert data from another table into an existing table, with an autoincrementing id?

  21. 21

    Excel How to import data from SQL Server using Transact SQL

  22. 22

    Excel How to import data from SQL Server using Transact SQL

  23. 23

    SQL Server, How to generate an `INSERT` statement for the rows in an existing table?

  24. 24

    How to Insert xml data into SQL Server table?

  25. 25

    Import Excel data into an existing SQL Server 2005 table

  26. 26

    how to copy only data from one database table to another database existing table in sql server

  27. 27

    How to copy Database from existing to new database sql script using sql server 2008 R2?

  28. 28

    SQL Insert data from 2 table to new table

  29. 29

    Import data to SQL Server table from Excel

HotTag

Archive