DATETIME SELECT SELECT INTO DATE PAD STRING DYNAMIC SQL CURSOR MONEY FORMAT PERCENT STORED PROCEDURE SQL SERVER AGENT JOB OPTIMIZATION WHILE LOOP OVER PARTITION BY UPDATE
 
 
SITE SEARCH SQLUSA.com VIDEOS
 
 
SQL E/BOOKS   WORLD, USA & SQL NEWS   FORMAT
SCRIPTS SQL 2005 SQL 2008 ARTICLES
How to find files with the xp_fileexist command?

The following Microsoft SQL Server T-SQL code sample illustrates how to apply the undocumented xp_fileexist with result returned in a table variable:

DECLARE @File TABLE (      FileExists smallint,

                                              InDirectory smallint,

                                              ParentDirExists smallint);

SET NOCOUNT ON;

DECLARE @FileName varchar(255);

SELECT @FileName='C:\config.cfg';

 

INSERT @File;

EXEC Master.dbo.xp_fileexist @filename;

 

SELECT * FROM @File;

GO

 

FileExists

InDirectory

ParentDirExists

1

0

1

 

-- Alternate script

DECLARE @Exists INT;

DECLARE @FileName varchar(255);

SELECT  @FileName = 'C:\config.cfg';

 

EXEC master.dbo.xp_fileexist @FileName, @Exists OUT;

 

SELECT [Exists] = @Exists;

 

Exists

1

 

Related article:

Finding Files: Part 1 T-SQL

 

Exam Prep 70-461
SQL 2016 DESIGN & PROGRAMMING
 
 
 
DATETIME SELECT SELECT INTO DATE PAD STRING DYNAMIC SQL CURSOR MONEY FORMAT PERCENT STORED PROCEDURE SQL SERVER AGENT JOB OPTIMIZATION WHILE LOOP OVER PARTITION BY UPDATE