Solved

SQL 2000 checking if file exist on disk and update status

Posted on 2009-04-08
2
655 Views
Last Modified: 2012-06-27
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
Comment
Question by:Kechka
2 Comments
 
LVL 5

Assisted Solution

by:TheVeee
TheVeee earned 50 total points
ID: 24096407
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
 
LVL 10

Accepted Solution

by:
Kechka earned 0 total points
ID: 24302034
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

How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Using a hta file with MSSQL agent to schedule a script job 4 39
LTrim & Double Space Correction 5 40
Database Integrity 1 49
RAISERROR WITH NOWAIT 2 16
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question