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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Bulk insert using ASP/VBscript?

Author  Topic 

Quinn
Starting Member

3 Posts

Posted - 2007-01-05 : 04:29:27
Hi!

I'm trying to insert rows into an SQL Server table using a semicolon-separated text file as the source. The file continues approximately 4000 rows and I use the readLine() function to get the data ready for insert.

After reading a line I insert the row into SQL Server using a normal INSERT statement. I have tried this using only 100 test lines nand everything worked OK, but the first time I tried inserting all 4000 the web server seemed to go down.

Is this because SQL Server is not capable of such a bulk insert via web?
Is there something I could do to makes this easier?

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2007-01-05 : 05:26:01
how did it go down?
did your insert time out?



Go with the flow & have fun! Else fight the flow
blog thingie: http://weblogs.sqlteam.com/mladenp
Go to Top of Page

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2007-01-05 : 06:53:03
Why don't you read everything first into a recordset (assuming you are using ADO) and then dumping records in batch of say 100 records?
Reading file line by line and inserting each record will definitely make process slower.

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

Quinn
Starting Member

3 Posts

Posted - 2007-01-05 : 07:30:36
The recordset thing sounds smart.
Can anyone give me an example of how to do this?

Quinn
Go to Top of Page

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2007-01-05 : 08:03:14
This article nicely explains how you can read text files using ADO:
[url]http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnclinic/html/scripting03092004.asp[/url]

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

Quinn
Starting Member

3 Posts

Posted - 2007-01-08 : 05:11:43
Thanks for the tip, I think I'm getting there shortly.
You advised me to dump records in batches of 100. How can I do this? Do you have some example code?

Thanks for your help!
Go to Top of Page
   

- Advertisement -