Does SQL Azure Support Bulk Insert from a File?

  • I'm just curious if this would work.

    If I connect to SQL Azure using SSMS on my local machine and the C:\something\something.csv is on my local machine.

    DECLARE @sql VARCHAR(255)

    DECLARE @path VARCHAR(255)

    DECLARE @filename VARCHAR(255)

    SET @path = 'C:\something\'

    SET @filename = 'something.csv'

    SET @sql = 'BULK INSERT dbo.Plans FROM ''' + @path + @filename + ''' '

    + ' WITH (

    FIELDTERMINATOR = '','',

    ROWTERMINATOR = '''',

    FIRSTROW = 2

    ) '

    PRINT @sql

    --EXEC (sql)

  • you can use the .NET Frameworks SQLBulkCopy object , and use that to load via bulk copy, but not BULK INSERT command; that requires you to have already organized the data into a DataTable on the client side.

    if BULK INSERT were to be possible, the path to the file would be something like \\Your.Inernet.IP\c$\Somefolder\Somefile.csv, so that's not going to work.

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply