Gerrit Mantel
Programs SQL_SCALAR_FUNCTION - fun_FolderExist

Main program

Namefun_FolderExist
Type_descSQL_SCALAR_FUNCTION
CommentSQLServer User-Defined Function

PURPOSE
Check if folder exists.

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

EXAMPLES
SELECT dbo.fun_FolderExist('C:\Program Files')
1

SELECT dbo.fun_FolderExist('C:\xxxx')
0

-- IIF is available starting with SQL Server 2012
PRINT IIF(dbo.fun_FolderExist('C:\Program Files')=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 folder exists</description>
<generic>1</generic>
<author>Gerrit Mantel</author>
<created>2015-11-24</created>
<lastmodified>2026-01-23</lastmodified>
</program>
DescriptionCheck if folder exists
Minversion
Generic1
AuthorGerrit Mantel
Created2015-11-24 00:00:00
Lastmodified2026-01-23 00:00:00
Xp_cmdshell0
Ole_automation1
Subprogram_cnt0
Sourcecode