← Tutti gli articoli

How we can check for file exitence in a specified folder using TSQL

02 September 2010  ·  TSQL · Article  ·  60 visite

How we can check for file exitence in a specified folder using TSQL. One option to validate that a file exists or not is to use the master.dbo.xp_fileexist extended stored procedure.

 

SET NOCOUNT ON

declare @fileexist int
exec xp_fileexist 'c:\appoggio\bTreeDoc\-1-0000008-0001834.pdf', @fileexist OUTPUT
select @fileexist
if @fileexist >0
	BEGIN
		print 'file exists..'
		
	END
else
BEGIN
	print 'file doesn''t exists....'

END

Si è verificato un errore imprevisto. Ricarica

Rejoining the server...

Rejoin failed... trying again in seconds.

Failed to rejoin.
Please retry or reload the page.

The session has been paused by the server.

Failed to resume the session.
Please retry or reload the page.