I'm trying to use xp_fileexist against list of files. After reading the documentation I could find, I came up with the idea of creating a function then using it in the column list. The code previously displayed a list of filenames:3454.pdf7435.pdf213.docx6442.pdf2363.docx
create function myfn_FileExists ( @fullfilename nvarchar(max) ) returns bitAS BEGIN DECLARE @i int EXEC master..xp_fileexist @fullfilename, @i out RETURN @i ENDGOSELECT CASE WHEN se.ID IS NULL THEN NULL ELSE CAST(se.ID as NVARCHAR(MAX)) + se.fileExt END as [File Name], dbo.myfn_FileExists ('C:\Users\SomeDude\Desktop\Docs\' + CAST(se.ID as NVARCHAR(max)) + se.fileExt) as [File Exists]FROM .....GO
Although the code compiles and runs, the [File Exists] column always shows a NULL value. Can anyone spot my mistake?