Quantcast
Viewing all articles
Browse latest Browse all 12963

BULK INSERT

I don't know if this has been posted before. I have look around and could not find any similar question.

I am written a stored proc that will do a bulk load using bulk insert command. But I am getting an error msg 4861. below is my full error msg and my code. Can someone advice what I am doing wrong. The sql server engine is on a total different server from my text file. But they are all on the same network.

use test_sp
go

Declare @path nvarchar(max)
declare @str varchar (1000)
declare @Fulltblname varchar (1000)


Set @path ='\\myservername\ShareName\Path\FileName.txt'
Set @Fulltblname ='table1'

 

--bulk load the table with raw data
Set @str = 'BULK INSERT [dbo].['+@Fulltblname+'] 
FROM ' + char(39) + @Path + Char(39) + '
WITH 
(
FIELDTERMINATOR = ''|'',
FIRSTROW = 1,
ROWTERMINATOR =''\n'',
MAXERRORS = 0
  
);'

Exec sp_executesql @str




Errors getting below

 

Cannot bulk load because the file "\\myservername.domainname\ShareName\Path\FileName.txt" could not be opened. Operating system error code 5(Access is denied.).
Msg 4861, Level 16, State 1, Line 1
Cannot bulk load because the file "\\myservername.domainname\ShareName\Path\FileName.txt" could not be opened. Operating system error code 5(Access is denied.).
Mail queued.


Viewing all articles
Browse latest Browse all 12963

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>