Thursday, July 4, 2013

T-SQL to verify file exists

T-SQL to verify file exists

declare @file_path varchar(100)
declare @file_exists int

set @file_path = 'C:\Temp\RESOURCES_BKP_OUTPUT.xls'

exec master.dbo.xp_fileexist @file_path, @file_exists output

if @file_exists = 1
 Print 'File Exists'
else
 Print 'File not found'

No comments: