SQL Server csv in xml out Project Part 7


This entry is part 7 of 13 in the series SQL CSV XML Project

This is the code for usp_11CheckIfFileExists in our I Love Books project.

Before looking at all of the code below, we should have a look at our function. This function checks to see if a file exists.

Here is part of the code we are using in the stored procedure.

ALTER FUNCTION [dbo].[udf_FileExists](@path varchar(8000))
RETURNS BIT
AS
BEGIN
     DECLARE @result INT
     EXEC master.dbo.xp_fileexist @path, @result OUTPUT
     RETURN cast(@result AS BIT)

/*
Here is how you can use this function
=====================================
DECLARE @fileexists BIT;
SET @fileexists = dbo.udf_FileExists('c:\newdir\22.txt');
IF @fileexists = 0
	BEGIN
		PRINT 'file not found'
	END
ELSE
	BEGIN
		PRINT 'found file'
	END
*/
END;
Series Navigation<< SQL Server csv in xml out Project Part 6SQL Server csv in xml out Project Part 8 >>