Solved

SQL 2000 checking if file exist on disk and update status

Posted on 2009-04-08
2
658 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Is Your DevOps Pipeline Leaking?

Is your CI/CD pipeline a hodge-podge of randomly connected tools? You’ve likely got a tool to fix one problem & then a different tool to fix another, resulting in a cluster of tools with overlapping functionality. Learn how to optimize your pipeline with Gartner's recommendations

Question has a verified solution.

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

I'm trying, I really am. But I've seen so many wrong approaches involving date(time) boundaries I despair about my inability to explain it. I've seen quite a few recently that define a non-leap year as 364 days, or 366 days and the list goes on. …
A Stored Procedure in Microsoft SQL Server is a powerful feature that it can be used to execute the Data Manipulation Language (DML) or Data Definition Language (DDL). Depending on business requirements, a single Stored Procedure can return differe…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Viewers will learn how the fundamental information of how to create a table.

734 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