Log in
::
Register
::
Not logged in
Home
Tags
Articles
Editorials
Stairways
Forums
Scripts
Videos
Blogs
QotD
Books
Ask SSC
SQL Jobs
Training
Authors
About us
Contact us
Newsletters
Write for us
Recent Posts
Recent Posts
Popular Topics
Popular Topics
Home
Search
Members
Calendar
Who's On
Home
»
SQL Server 2005
»
SQL Server 2005 Integration Services
»
insert data from file to sql table
insert data from file to sql table
Rate Topic
Display Mode
Topic Options
Author
Message
harri.reddy
harri.reddy
Posted Wednesday, October 24, 2012 9:53 AM
SSC-Enthusiastic
Group: General Forum Members
Last Login: Thursday, February 21, 2013 12:01 PM
Points: 149,
Visits: 346
hi
i have flat file like this
TH*4.2*876545*P~~IO*3456*color~
now i have two tables
create table table1
(id nvarchar(10),
t1 int,
t2 int primary key,
t3 nvarchar(5),
i1 int foreign key table2(i1))
create table table2(
id nvarchar(10),
i1 int primary key,
i2 nvarchar(10))
now i need to insert this file record into table describe below.
i cannot do it mannualy.
if i use ssis package ,how can i1 value of table 1 will automatically insetered.
any other way
thanks
Post #1376562
GSquared
GSquared
Posted Wednesday, October 24, 2012 9:57 AM
SSCoach
Group: General Forum Members
Last Login: Yesterday @ 1:55 PM
Points: 15,442,
Visits: 9,571
Insert it into a staging table first.
Is there anything in the file that identifies the rows uniquely? Like a row number or anything like that?
- Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
Property of The Thread
"Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon
Post #1376566
harri.reddy
harri.reddy
Posted Wednesday, October 24, 2012 10:40 AM
SSC-Enthusiastic
Group: General Forum Members
Last Login: Thursday, February 21, 2013 12:01 PM
Points: 149,
Visits: 346
no in the file there is no row number
i need to know how to insert data into table which has primary -?foreign key relation.
as you said staging table
can you give me example.like i have given you two tables,can you explain me with that example
Post #1376586
Koen Verbeeck
Koen Verbeeck
Posted Thursday, October 25, 2012 12:24 AM
SSCrazy Eights
Group: General Forum Members
Last Login: Today @ 6:51 AM
Points: 9,372,
Visits: 6,470
harri.reddy (10/24/2012)
no in the file there is no row number
i need to know how to insert data into table which has primary -?foreign key relation.
as you said staging table
can you give me example.like i have given you two tables,can you explain me with that example
Can you give a bit more sample data and the desired output? It's not really clear what you want to do with the flat file rows.
How to post forum questions.
Need an answer? No, you need a question.
What’s the deal with Excel & SSIS?
Member of
LinkedIn
. My blog at
LessThanDot
.
MCSA SQL Server 2012 - MCSE Business Intelligence
Post #1376796
harri.reddy
harri.reddy
Posted Thursday, October 25, 2012 6:59 AM
SSC-Enthusiastic
Group: General Forum Members
Last Login: Thursday, February 21, 2013 12:01 PM
Points: 149,
Visits: 346
TH*4.2*876545*P~~IO*3456*color~ n
my data would be like this
table1
id t1 t1 t3 i1
TH 4.2 876545 p 3456
table2
id i1 i2
iO 3456 color
i need to do it using ssis
here,i1 is primary key of table2 , which is foreign key of table1
thanks
Post #1376964
Koen Verbeeck
Koen Verbeeck
Posted Thursday, October 25, 2012 7:07 AM
SSCrazy Eights
Group: General Forum Members
Last Login: Today @ 6:51 AM
Points: 9,372,
Visits: 6,470
Use * as the delimiter for your flat file in the flat file connection manager.
Duplicate the stream using the Multicast.
Put two OLE DB destinations to your table, but write only the columns needed for the corresponding table.
How to post forum questions.
Need an answer? No, you need a question.
What’s the deal with Excel & SSIS?
Member of
LinkedIn
. My blog at
LessThanDot
.
MCSA SQL Server 2012 - MCSE Business Intelligence
Post #1376970
harri.reddy
harri.reddy
Posted Thursday, October 25, 2012 7:23 AM
SSC-Enthusiastic
Group: General Forum Members
Last Login: Thursday, February 21, 2013 12:01 PM
Points: 149,
Visits: 346
but how can i write primary -?foreign key in first table(i1)
Post #1376977
Koen Verbeeck
Koen Verbeeck
Posted Thursday, October 25, 2012 7:29 AM
SSCrazy Eights
Group: General Forum Members
Last Login: Today @ 6:51 AM
Points: 9,372,
Visits: 6,470
You just write the same column (number 5 in your flat file) twice to the database.
Once as a PK, once as a FK. So you need two OLE DB Destinations in your dataflow.
How to post forum questions.
Need an answer? No, you need a question.
What’s the deal with Excel & SSIS?
Member of
LinkedIn
. My blog at
LessThanDot
.
MCSA SQL Server 2012 - MCSE Business Intelligence
Post #1376982
harri.reddy
harri.reddy
Posted Thursday, October 25, 2012 8:55 AM
SSC-Enthusiastic
Group: General Forum Members
Last Login: Thursday, February 21, 2013 12:01 PM
Points: 149,
Visits: 346
u mean in header row delimiter i need to put *
Post #1377054
« Prev Topic
|
Next Topic »
Permissions
You
cannot
post new topics.
You
cannot
post topic replies.
You
cannot
post new polls.
You
cannot
post replies to polls.
You
cannot
edit your own topics.
You
cannot
delete your own topics.
You
cannot
edit other topics.
You
cannot
delete other topics.
You
cannot
edit your own posts.
You
cannot
edit other posts.
You
cannot
delete your own posts.
You
cannot
delete other posts.
You
cannot
post events.
You
cannot
edit your own events.
You
cannot
edit other events.
You
cannot
delete your own events.
You
cannot
delete other events.
You
cannot
send private messages.
You
cannot
send emails.
You
may
read topics.
You
cannot
rate topics.
You
cannot
vote within polls.
You
cannot
upload attachments.
You
may
download attachments.
You
cannot
post HTML code.
You
cannot
edit HTML code.
You
cannot
post IFCode.
You
cannot
post JavaScript.
You
cannot
post EmotIcons.
You
cannot
post or upload images.
Copyright © 2002-2013 Simple Talk Publishing. All Rights Reserved.
Privacy Policy.
Terms of Use.
Report Abuse.