简体   繁体   中英

BULK INSERT Syntax SQL

I can not get a SQL Bulk Insert Statement to Run via C# on my Web Server or locally. I am trying to import data from a text file into a SQL Web Server.

After I connect to the Web server / SQL Server the The statement I am using is as as follows..

BULK INSERT dbo.FNSR
            FROM 'http:\\yahoodd.velocitytrading.net\txtfiles\FNSR.txt'
            WITH
            ( 
                FIRSTROW = '2',
                FIELDTERMINATOR = '\t', 
                ROWTERMINATOR = '\n'
)

then I get this error.

Cannot bulk load because the file "\\yahoodd.velocitytrading.net\\txtfiles\\FNSR.txt" could not be opened. Operating system error code 53(The network path was not found.).

I have tried this with 'http"://webserver.remotefile.txt' as listed above also... with a slightly different result (error code 123 dir, path not valid )

Any ideas?? I can not upload the txt file to the WebServer as a local txt file... what I am I doing wrong.. how is this supposed to work?

To specify a shared data file, use its universal naming convention (UNC) name, which takes the general form, \\Servername\\Sharename\\Path\\Filename. Additionally, the account used to access the data file must have the permissions that are required for reading the file on the remote disk.

BULK INSERT AdventureWorks2008R2.Sales.SalesOrderDetail
   FROM '\\computer2\salesforce\dailyorders\neworders.txt';
GO

http://msdn.microsoft.com/en-us/library/ms175915.aspx

Its two slashes and no http

BULK INSERT dbo.FNSR FROM '\\yahoodd.velocitytrading.net\txtfiles\FNSR.txt' 
WITH ( FIRSTROW = '2', FIELDTERMINATOR = '\t', ROWTERMINATOR = '\n' )

It has to be a local drive.

The part FROM 'http:\\yahoodd.velocitytrading.net\\txtfiles\\FNSR.txt' should be replaced by C:.......\\some.txt .

If it's from http://... you will have to stream through it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM