Skip to content

Instantly share code, notes, and snippets.

@roe3p
Last active March 1, 2016 15:12
Show Gist options
  • Save roe3p/76e04047c3cb448facd3 to your computer and use it in GitHub Desktop.
Save roe3p/76e04047c3cb448facd3 to your computer and use it in GitHub Desktop.
T-SQL function to check whether a file exists
-- =============================================
-- Author: Rohan Shenoy
-- Create date: 2013-10-28
-- Description: Function to return whether file exists
-- =============================================
CREATE FUNCTION [dbo].[fnFileExists] (@path varchar(512)) RETURNS BIT
AS
BEGIN
DECLARE @result INT
EXEC master.dbo.xp_fileexist @path, @result OUTPUT
RETURN cast(@result AS BIT)
END
GO
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment