- SQL Server csv in xml out Project
- SQL Server csv in xml out Project Part 2
- SQL Server csv in xml out Project Part 3
- SQL Server csv in xml out Project Part 4
- SQL Server csv in xml out Project Part 5
- SQL Server csv in xml out Project Part 6
- SQL Server csv in xml out Project Part 7
- SQL Server csv in xml out Project Part 8
- SQL Server csv in xml out Project Part 9
- SQL Server csv in xml out Project Part 10
- SQL Server csv in xml out Project Part 11
- SQL Server csv in xml out Project Part 12
- SQL Server Move Data to a File Part 13
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;