Gerrit Mantel
Programs SQL_SCALAR_FUNCTION - fun_FileExist

Main program

Namefun_FileExist
Type_descSQL_SCALAR_FUNCTION
CommentSQLServer User-Defined Function

PURPOSE
Check if file exists.

Return value (BIT):
0 (False) - File does not exist
1 (True) - File exists

EXAMPLES
SELECT dbo.fun_FileExist('C:\oneTouch_drive.cvf')
1

SELECT dbo.fun_FileExist('C:\xxxx.txt')
0

-- IIF is available starting with SQL Server 2012
PRINT IIF(dbo.fun_FileExist('C:\oneTouch_drive.cvf')=1,'Yes','No')
Yes

HISTORY
2015-11-24 - Created function
2024-02-09 - Changed history table
2026-01-23 - Changed return value type to BIT

TAGS
<program>
<description>Check if file exists</description>
<generic>1</generic>
<author>Gerrit Mantel</author>
<created>2015-11-24</created>
<lastmodified>2026-01-23</lastmodified>
</program>
DescriptionCheck if file exists
Minversion
Generic1
AuthorGerrit Mantel
Created2015-11-24 00:00:00
Lastmodified2026-01-23 00:00:00
Xp_cmdshell0
Ole_automation1
Subprogram_cnt0
Sourcecode