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
 SQL Server 2000 Forums
 Import/Export (DTS) and Replication (2000)
 Bulk Inserts from a passed variable

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2002-06-24 : 01:19:58
Russel writes "I need to do a bulk insert into an MS SQL table with out creating a file. I see from the MS SQL book online that Bulk Inserts can be performed from a file, but how do I do this from a variable? Writing a file on either the web or the SQL servers is out of the question.

Russel"

robvolk
Most Valuable Yak

15732 Posts

Posted - 2002-06-24 : 07:57:42
quote:
Writing a file on either the web or the SQL servers is out of the question

Then there is no way to use BULK INSERT, or DTS, or bcp for that matter.

You could try passing the data as a comma-separated value (CSV) into a stored procedure and parsing it, then inserting it. Take a look at these:

http://www.sqlteam.com/SearchResults.asp?SearchTerms=csv

Go to Top of Page

MakeYourDaddyProud

184 Posts

Posted - 2002-06-24 : 08:06:54
More clarification is required here. Where is your data coming from? Is it another database, Access, a file what? Also is the data held on another source such as a romote FS?

Dan

Go to Top of Page

rmadere
Starting Member

3 Posts

Posted - 2002-06-24 : 08:54:03
quote:

More clarification is required here. Where is your data coming from? Is it another database, Access, a file what? Also is the data held on another source such as a romote FS?

Dan





Dan,

The data will be coming from a submitted web form. There will be an arbitrary number of items to insert into the table.

Russel

Go to Top of Page

robvolk
Most Valuable Yak

15732 Posts

Posted - 2002-06-24 : 09:01:50
Perfect! In addition to the CSV articles, take a look at these:

http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=12538
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=13935

I've used CSV and fixed-length parameter passing for exactly the same situation you have, and they work very well indeed.

Go to Top of Page

rmadere
Starting Member

3 Posts

Posted - 2002-06-24 : 16:00:21
quote:

Perfect! In addition to the CSV articles, take a look at these:

http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=12538
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=13935

I've used CSV and fixed-length parameter passing for exactly the same situation you have, and they work very well indeed.





Thanks for pointing those out. My form is generating a list of lists. It comes in the form ProductID-SerialNumber,. Using the sp_ParseArray stored procedure, I think I can write one that will parse out the Model ID and Serial Number pairs and the parse the sublist and do my Insert (or Update).

Am I completely off the wall here?

Russel
Coming back to post after I test this bugger :)

Go to Top of Page

rmadere
Starting Member

3 Posts

Posted - 2002-06-24 : 16:38:07
quote:

- snip -

Russel
Coming back to post after I test this bugger :)




I tested it and it seems to work. Thanks.

Go to Top of Page
   

- Advertisement -