BULK INSERT Syntax SQL

醉酒当歌 提交于 2020-02-04 03:49:13

问题


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?


回答1:


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




回答2:


Its two slashes and no http

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



回答3:


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.



来源:https://stackoverflow.com/questions/4415037/bulk-insert-syntax-sql

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!