Author |
Message |
rykard
Occasionally has a life
Joined: Sat Nov 28, 2009 5:28 pm Posts: 228
|
HI, can anyone help me? I am a trying to write a simple SQL script to check whether a file exists of not. I have tracked down xp_fileexist but this only seems to work in a root directory  and all my files wil be in subdirectories... is there another command I am missing or is it not possible?
_________________ cheers Rich
A Vision of a Champion is someone who is bent over, drenched with sweat, at the point of exhaustion, when no one else is watching
|
Wed Jul 07, 2010 11:34 am |
|
 |
EddArmitage
I haven't seen my friends in so long
Joined: Thu Apr 23, 2009 9:40 pm Posts: 5288 Location: ln -s /London ~
|
I don't understand. Can you post what you've got so far? SQL is for querying and modifying databases - is this what you mean and if so can you outline your db structure?
|
Wed Jul 07, 2010 1:00 pm |
|
 |
rykard
Occasionally has a life
Joined: Sat Nov 28, 2009 5:28 pm Posts: 228
|
What I have is a PDF path in a db record, for some reason a PDF hasn't been created and I am trying to track down easily a list of the missing PDFs,
so basically what I am trying to do is below in 'english'..
select * from table T1 where T1.PDF_Path doesn't exist
_________________ cheers Rich
A Vision of a Champion is someone who is bent over, drenched with sweat, at the point of exhaustion, when no one else is watching
|
Wed Jul 07, 2010 1:06 pm |
|
 |
jonlumb
Spends far too much time on here
Joined: Thu Apr 23, 2009 6:44 pm Posts: 4141 Location: Exeter
|
My understanding is that the functionality isn't there. Yes you need the SQL to read the file names / paths out of the database, but there's no way to get SQL to loko through the file/folder structure. Any other programming language should be fine though.
_________________ "The woman is a riddle inside a mystery wrapped in an enigma I've had sex with."
|
Wed Jul 07, 2010 1:11 pm |
|
 |
forquare1
I haven't seen my friends in so long
Joined: Thu Apr 23, 2009 6:36 pm Posts: 5150 Location: /dev/tty0
|
You could try the xp_cmdshell command. You could then have this fire off a script which would allow you to use all the usual UNIX/Windows command line tools to search for files...
|
Wed Jul 07, 2010 1:14 pm |
|
 |
rykard
Occasionally has a life
Joined: Sat Nov 28, 2009 5:28 pm Posts: 228
|
thanks guys, I was kinda figuring I was asking the impossible... guess i wil have to write a program to do it...
_________________ cheers Rich
A Vision of a Champion is someone who is bent over, drenched with sweat, at the point of exhaustion, when no one else is watching
|
Wed Jul 07, 2010 1:38 pm |
|
 |
EddArmitage
I haven't seen my friends in so long
Joined: Thu Apr 23, 2009 9:40 pm Posts: 5288 Location: ln -s /London ~
|
It sounds perfectly scriptable, as Ben says. You need a script that: - Executes the SQL to get the file paths
- Grabs the results from the SQL
- For each file path
- Browses to see if the file exists
- If it doesn't add it to an output file
I don't have much experience of Windows scripting, but it'd be doable in Bash for example.
|
Wed Jul 07, 2010 2:27 pm |
|
 |
finlay666
Spends far too much time on here
Joined: Thu Apr 23, 2009 9:40 pm Posts: 4876 Location: Newcastle
|
bash, perl, a quick c# command line tool sql wont help find the file, its a db language, you will just get the file name (possibly path)
_________________TwitterCharlie Brooker: Macs are glorified Fisher-Price activity centres for adults; computers for scaredy cats too nervous to learn how proper computers work; computers for people who earnestly believe in feng shui.
|
Wed Jul 07, 2010 11:00 pm |
|
 |
EddArmitage
I haven't seen my friends in so long
Joined: Thu Apr 23, 2009 9:40 pm Posts: 5288 Location: ln -s /London ~
|
Yup. My understanding was there's a DB with file paths in it somewhere, that needs querying first.
|
Thu Jul 08, 2010 7:54 am |
|
 |
rykard
Occasionally has a life
Joined: Sat Nov 28, 2009 5:28 pm Posts: 228
|
that is correct, xp_fileexists only works to a single level. I am, going to write a program in the app, it wil take a lot longer but that's the only solution with my limited sql knowledge.
thanks for the help everyone, I may revisit this when I have sometime to look into it properly...
_________________ cheers Rich
A Vision of a Champion is someone who is bent over, drenched with sweat, at the point of exhaustion, when no one else is watching
|
Thu Jul 08, 2010 8:23 am |
|
 |
Nick
Spends far too much time on here
Joined: Thu Apr 23, 2009 11:36 pm Posts: 3527 Location: Portsmouth
|
 That is all.
_________________
|
Tue Aug 10, 2010 6:12 pm |
|
|