.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Forum >> ADO.Net >> Post New QuestionBookmark and Share Subscribe to Forum

How to use bulk insert in sql server?

Posted By: Ramesh     Posted Date: March 02, 2010    Points:2   Category :ADO.Net
Hi,

I heard that we can use bulk insert of in sql server using ado.net. how to perform bulk insert in sql server in asp.net?

Regards
Ramesh

Responses
Author: Syed Shakeer Hussain             
Posted Date: March 02, 2010     Points: 5   

Hi Ramesh,
see the below link for more information

http://www.codeproject.com/KB/database/SqlBulkCopy.aspx

Author: Sagar Pardeshi             
Posted Date: March 02, 2010     Points: 5   
Author: Lalij Mer             
Posted Date: March 03, 2010     Points: 5   
Author: abhay             
Posted Date: March 04, 2010     Points: 5   

Hi Ramesh,

You can do it uin sqlserver.Just create a procedure and pass the paath of the csv file nad the procedure will be like this

set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go



ALTER PROCEDURE [dbo].[ADMIN_UPLOAD] 'D:\Test.xls' (
@FILENAME AS VARCHAR(200)
)
AS

BEGIN

CREATE TABLE #tempTable (

CustomerName varchar(300),
OrderID varchar(300) )


BULK INSERT OrdersBulk
FROM 'D:\Tes.xls'
WITH
(
FIELDTERMINATOR = ',', //specify the FIELDTERMINATOR
ROWTERMINATOR = '\n' //specify the ROWTERMINATOR

)


insert into OrdersBulk(CustomerName) select CustomerName from #tempTable

insert into OrdersBulk(OrderID) select OrderID from #tempTable

end




Post Reply

You must Sign In To post reply
 
 
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery
JavaScript/VBScriptBiztalkWPFPatten/PracticesWCFOthers
www.DotNetSpark.comUnAnsweredAll

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend