Philippe Renaud
asked on
SQL see if file exists
Hello EE,
i have a folder where it could contains multiple files...
something like:
EE001.doc
abc.pdf
EE002.doc
EE001.pdf
How can I know if a file or more exists without giving the extension ?
I know there is exec master.dbo.xp_fileexist [@stringname]
but i need to put extension...
here in my example I would like to see that if I search with the name EE001 well it exists because there is a .doc and a .pdf
any idea ? I tried exec master.dbo.xp_fileexist "EE001.*" but does not work
i have a folder where it could contains multiple files...
something like:
EE001.doc
abc.pdf
EE002.doc
EE001.pdf
How can I know if a file or more exists without giving the extension ?
I know there is exec master.dbo.xp_fileexist [@stringname]
but i need to put extension...
here in my example I would like to see that if I search with the name EE001 well it exists because there is a .doc and a .pdf
any idea ? I tried exec master.dbo.xp_fileexist "EE001.*" but does not work
ASKER
Yes but if I dont type at the end the .doc how can I search the file ?
my question was lets say I dont know the extension is it possible to search with a .* or % for many
my question was lets say I dont know the extension is it possible to search with a .* or % for many
I'm sorry, I completely mis-read your question.
Just leave off the extension:
exec master.dbo.xp_fileexist 'C:\Documents and Settings\me\Desktop\EE001'
Just leave off the extension:
exec master.dbo.xp_fileexist 'C:\Documents and Settings\me\Desktop\EE001'
You need to mention typical 8.3 naming conversion
exec master.dbo.xp_fileexist 'C:\Docume~1\me\Desktop\EE 001.doc'
try something on C:\
exec master.dbo.xp_fileexist 'C:\EE001.doc'
exec master.dbo.xp_fileexist 'C:\Docume~1\me\Desktop\EE
try something on C:\
exec master.dbo.xp_fileexist 'C:\EE001.doc'
also, xp_fileExist checks for that file on the server where you installed the sql server and wont check on your local machine. for searching files on the network drives, your sql server service account should have sufficeint permission to see the content of that network folder
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
aneeshattingal,
Everything I posted was a result of testing in my environment and my machine is a client.
Everything I posted was a result of testing in my environment and my machine is a client.
Should find EE001.doc on your desktop.
The stored procedure does run under the sql user's account, so you may run into problems if you don't have the right security credentials on the network.
Here is a post explaining a work-around that you can try if you need to.
http://www.sqlservercentral.com/Forums/Topic533876-146-2.aspx