Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
Savi
Starting Member
1 Post |
Posted - 2011-02-16 : 00:30:14
|
Hi Friends, I am having a scenario of inserting data from flat file to sql server in SSISThe requirements are1.Flat file consisting of 100 records2.program should do a batch insert of say 10 records at a time in a sql server tableI dont know how can we insert the records in a batch..Is there any solution for it..Please guide meSavitha |
|
YellowBug
Aged Yak Warrior
616 Posts |
Posted - 2011-02-17 : 05:22:08
|
You can specify the batch size in the Advanced Editor for ADO NET Destination.Look under the Custom Properties for BatchSize. |
|
|
joe_bolla
Starting Member
1 Post |
Posted - 2011-12-05 : 06:45:34
|
What you can do is read the content from the flat file, format the data you want to insert into sql server into an XML format. the use SQL Server XML to insert it in one go as follows:1. You declare and set an xml variabledeclare @test nvarchar(max), @testxml xmlset @test = '<topic><dialog id="1" answerId="41"> <comment>comment 1</comment> </dialog> <dialog id="2" answerId="42" > <comment>comment 2</comment> </dialog> <dialog id="3" answerId="43" > <comment>comment 3</comment> </dialog> </topic>' set @testxml = cast(@test as xml)2. You run a simple XPath Query as follows: insert @answerTemp SELECT ParamValues.ID.value('@id','int') , ParamValues.ID.value('@answerId','int') , ParamValues.ID.value('(comment)[1]','VARCHAR(1000)') FROM @testxml.nodes('topic/dialog') as ParamValues(ID) View more details and code comments here: http://www.cyberminds.co.uk/blog/articles/how-to-insert-multiple-rows-in-sql-server.aspx Thanks |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-12-05 : 06:54:51
|
quote: Originally posted by Savi Hi Friends, I am having a scenario of inserting data from flat file to sql server in SSISThe requirements are1.Flat file consisting of 100 records2.program should do a batch insert of say 10 records at a time in a sql server tableI dont know how can we insert the records in a batch..Is there any solution for it..Please guide meSavitha
Why not dump the entire contents onto a staging table with an identity column and then use looping logic to fetch 10 records at a time from it?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
|
|
|
|
|