Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Bulk Insert and xp_fileexist ... SQL2005

Author  Topic 

mikenason
Starting Member

13 Posts

Posted - 2008-01-15 : 10:42:16
I am attemting to Bulk Insert a file if it exists, pass over the code if it does not exist. If the file does exist the code works correctly, if the file does not exist I keep getting the error;

Cannot bulk load. The file "\\hornet\ops$\Data\Out\Today\Bank\FTP.cmpayach.txt" does not exist.

The odd thing is that this code works correctly on my other SQL2005 server

my code.....


EXEC master..xp_fileexist '\\hornet\ops$\Data\Out\Today\Bank\FTP.cmpayach.txt', @exists output
if @exists = 1
begin
truncate table dbo.OST_NACHA_Data_Load
bulk insert OST_NACHA_Data_Load from '\\hornet\ops$\Data\Out\Today\Bank\FTP.cmpayach.txt' with
(
datafiletype = 'char',
rowterminator = '\n'
)
end

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-01-15 : 10:47:55
Do the new user have proper permissions and security rights to the unc path and the file?



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page
   

- Advertisement -