Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

xp_fileexist follow up question

Status
Not open for further replies.
Apr 3, 2003
180
US
I recently got some great help with the xp_fileexist sp, in a test lab I tried to use this sp to see if a file exists on a network share not on a local disk and it would not work. This is the code, which I recevied from gmmastros (thanks again) that works great on the local machine.

Declare @FileExists Int
exec master..xp_fileexist 'C:\document.txt', @FileExists Out
If @FileExists = 1
Select 'File Does Exist'
Else
Select 'File Not Found'

When this is modified to look for a file on another server like this,

Declare @FileExists Int

exec master..xp_fileexist '\\server-1\C$\document.txt', @FileExists Out

If @FileExists = 1
Select 'File Does Exist'
Else
Select 'File Not Found'

I always get File Not Found even though the file is there.
On the same pc that this sp is being run from I can type \\server-1\C$\document.txt into either command prompt or run and I can get to this file. Any help would be great. I can easily get around this using .net code to check for this file and copy it to the sql machine but I would like to know what I am doing wrong as far as this sp is concerned.
Thanks for your time.

"I hear and I forget. I see and I remember. I do and I understand."
- Confucius (551 BC - 479)
 
My best guess is a security issue.

Click Start->Run
Type: Services.msc
Scroll down to MSSQLSERVER
Right Click -> Properties
Click on: 'Log On' Tab

xp_fileexists is executed using this account, which probably doesn't have rights to the other computer.

Make sense?



-George

"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
Thanks I will check this tomorrow, I thought it used the account that I logged on to the sql box with, which does have access to this other server. Thanks again.

"I hear and I forget. I see and I remember. I do and I understand."
- Confucius (551 BC - 479)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top