1

I am using SQLDOM to retrieve stock prices from a website and the response is in a variable. The response is in a CSV Format.

I can bulk insert from the CSV into a physical file into the table but I need to insert from the memory varaible without saving the file to the hard drive.

How can I bulk insert into this table without having to save the content off? I have to skip the data header row.

Current Step 1

Using SQL:DOM I obtain the data in a memory variable called @HTML

EXEC master.[sdom].[sputilGetHTTP] 
@URL = @URL_Build,
@ResponseText = @HTML OUTPUT,
@ContentType = 'text/csv',
@SuppressResultset = 1

The data is formatted as csv with a ' ' to denote the LF & CR

Date,Open,High,Low,Close,Volume 13-Apr-17,6.61,6.61,6.11,6.36,316044 12-Apr-17,6.54,6.78,6.25,6.50,561519 11-Apr-17

Current Step 2

I save the file manually to a csv file on the hard drive

Current Step 3

I import the data into a temp table that I can access for my needs

Create table #List
(
 [Date] varchar(15),
 [Open] varchar(15),
 [High] varchar(15),
 [Low] varchar(15),
 [Close] varchar(15),
 [Volume] varchar(15),
)

bulk insert #List
FROM 'C:\Download\Import.csv'
 WITH
 (
 FIELDTERMINATOR = ',',
 FIRSTROW = 2,
 ROWTERMINATOR = ' '
 )

Needed Solution

Instead of copying the contents of the memory variable to the hard drive to import it as a CSV skipping the header row. Is there a way to use a memory variable as the csv file in the bulk insert statement skipping the header row?

asked Apr 15, 2017 at 12:57
1

0

Know someone who can answer? Share a link to this question via email, Twitter, or Facebook.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.