Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Check to see if a file exists from a stored procedure.

Status
Not open for further replies.

MarkWilliamson

Programmer
Apr 1, 2002
34
US
Ok guys be easy as I am new to the SQL Programming game. :)

I would like to create a stored procedure which will run periodically throughout the day - this procedure would check to see if a certain file exists in a directory. If the file is found then I would kick off another job.

Is this possible ? If so, how ?

Thanks in advance to all who reply !
 
May want to take a look at this example ...

Code:
sp_MSexists_file

Used to determine whether a particular file exists in a particular folder or not.

Syntax 

EXEC sp_MSexits_file full_path, filename 

where

full_path - is the full path to the file name, full_path is nvarchar(512)

filename - is the file name, filename is nvarchar(255)

To check if file textcopy.exe exists in the C:\MSSQL7\BINN\ directory (path by default), run:
DECLARE @retcode int

EXEC @retcode = sp_MSexists_file 'C:\MSSQL7\BINN\', 'textcopy.exe'

IF @retcode = 1

PRINT 'File Exist'

ELSE

PRINT 'File does not Exist'

Enjoy!

Thanks

J. Kusch
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top