Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Does SQL Azure Support Bulk Insert from a File? Expand / Collapse
Author
Message
Posted Thursday, October 20, 2011 10:33 AM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Monday, July 7, 2014 9:08 AM
Points: 202, Visits: 565
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)

Post #1193887
Posted Thursday, October 20, 2011 10:40 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Today @ 9:11 AM
Points: 12,881, Visits: 31,823
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

--There is no spoon, and there's no default ORDER BY in sql server either.
Actually, Common Sense is so rare, it should be considered a Superpower. --my son
Post #1193890
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse