Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 665
  • Last Modified:

SQL 2000 checking if file exist on disk and update status

I have SQL base developed by someone else, I don't have option to contact for support.
I have a field file_name which contains path to file (\\servername\folder\...)
I have a field file_status which contains file status (D exist, DD deleted)

I have application which allow users to doubleclick to query result and open file in viewer.
Everything worked fine until few days. Now after every restart files change status to DD even they exist on disk, and aplication is showing that file is deleted. If I add a new file status is D which is OK. I am trying to figure what is the reason, but in meantime I will like to have temporary solution to allow users to see files.

I will like to have query which I will run when needed. I need to check if file with status DD and ID with name in file_name exist on disk and update that ID file status to D.

I hope I was clear enough.
0
Kechka
Asked:
Kechka
2 Solutions
 
TheVeeeCommented:
Following your question.  

Things to check why your program isnt working anymore:
1.  What userid is your program running under? It may have lost authority to the directory to read.
2.  Is the directory the program is reading on the same machine?  If not, see if you can ping the machine from the machine running the program.
3.  If running against another machine for files, has the userid lost access to that machine?

The reason a program was created to run against your database to update statuses, is because sql was created to do maintenance against the database, not to process against the machine.  Your asking sql to process against the machine to find files and so forth, it wont, it will just update/delete/add against a database.
 
0
 
KechkaAuthor Commented:
I'll found this:
if object_id('tempdb..#temp') is not null
drop table #temp

CREATE TABLE #Temp(Directory varchar(1000),depth int)
INSERT INTO #temp
EXEC master..xp_dirtree 'C:\',1,0
IF @@ROWCOUNT > 0
 Print 'Path Exists'
ELSE
PRINT 'DIR Does Not Exist'
Will try to use...
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now