SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Help required in SSIS 2008


Help required in SSIS 2008

Author
Message
patel.ritesh.r
patel.ritesh.r
Forum Newbie
Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)

Group: General Forum Members
Points: 4 Visits: 12
Hello,

I am new to SSIS. Can anyone help me provide solution for below mentioned scenario…

I want to transfer data from Excel file to SQL server table based on the values of one column of the source, the rows needs to be duplicated in the destination (SQL table).

Example:

Source (Excel file)
"Req ID" "Desc" "Number"

A Req A 4
B Req B 2
C Req C 1

Destination (SQL Table) – Rows needs to be duplicated based on the “Number” column in the source and to make each row is unique, Req Number needs to be added for each row.

"Req ID" "Req Number" "Desc"

A 1 Req A
A 2 Req A
A 3 Req A
A 4 Req A
B 1 Req B
B 2 Req B
C 1 Req C

Thanks.
Mr. Kapsicum
Mr. Kapsicum
Ten Centuries
Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)

Group: General Forum Members
Points: 1161 Visits: 1027
patel.ritesh.r (9/3/2013)
Hello,

I am new to SSIS. Can anyone help me provide solution for below mentioned scenario…

I want to transfer data from Excel file to SQL server table based on the values of one column of the source, the rows needs to be duplicated in the destination (SQL table).

Example:

Source (Excel file)
"Req ID" "Desc" "Number"

A Req A 4
B Req B 2
C Req C 1

Destination (SQL Table) – Rows needs to be duplicated based on the “Number” column in the source and to make each row is unique, Req Number needs to be added for each row.

"Req ID" "Req Number" "Desc"

A 1 Req A
A 2 Req A
A 3 Req A
A 4 Req A
B 1 Req B
B 2 Req B
C 1 Req C

Thanks.



first you can load your data in a staging table which is as it is as your excel file.

then you can write a T-sql script that inserts your data in the destination tables(you can use Execute sql task for this)
patel.ritesh.r
patel.ritesh.r
Forum Newbie
Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)

Group: General Forum Members
Points: 4 Visits: 12
Hello,

Thank you for replying on the post.

Can you also please help me with the T-SQL script to insert data
Koen Verbeeck
Koen Verbeeck
One Orange Chip
One Orange Chip (27K reputation)One Orange Chip (27K reputation)One Orange Chip (27K reputation)One Orange Chip (27K reputation)One Orange Chip (27K reputation)One Orange Chip (27K reputation)One Orange Chip (27K reputation)One Orange Chip (27K reputation)

Group: General Forum Members
Points: 27295 Visits: 13268
You could also do it with some .net coding in an asynchronous script component.
You read the value from number and use it in a for loop.
In each iteration of the loop, you output a row with the current value of the iterator.


How to post forum questions.
Need an answer? No, you need a question.
What’s the deal with Excel & SSIS?
My blog at SQLKover.

MCSE Business Intelligence - Microsoft Data Platform MVP
Phil Parkin
Phil Parkin
SSCoach
SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)

Group: General Forum Members
Points: 18395 Visits: 20423
patel.ritesh.r (9/9/2013)
Hello,

Thank you for replying on the post.

Can you also please help me with the T-SQL script to insert data


You could use a 'numbers' table to do this (1,2,3,4,5,6,7,8,9,...).

Join to the numbers table on

numbers.number <= stagingtable.NumOfRowsToCreate

And that will give you the required number of rows.


Help us to help you. For better, quicker and more-focused answers to your questions, consider following the advice in this link.

If the answer to your question can be found with a brief Google search, please perform the search yourself, rather than expecting one of the SSC members to do it for you.

Please surround any code or links you post with the appropriate IFCode formatting tags. It helps readability a lot.
patel.ritesh.r
patel.ritesh.r
Forum Newbie
Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)

Group: General Forum Members
Points: 4 Visits: 12
Thank you Phil...
Great idea. It solves the problem. :-)
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search