Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 XP_FileExists

Author  Topic 

carumuga
Posting Yak Master

174 Posts

Posted - 2008-07-21 : 11:04:36
Hi

I'm trying to use this command from my workstation to see the direcory exist or not in the share directory. It doesnt give me the desired output. Though the file exist, i'm getting the return value 0

execute master..XP_FILEEXIST '\\MachineName\test'

Fileexist File Is A Directory Parent Directory Exists
0 0 0

Please help me on this issue.

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-07-21 : 11:08:30
If you want to see DIRECTORY, why use FILEEXIST?

Use xp_dirtree



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-07-21 : 11:08:58
Declare @Filname nVarChar(260)
Declare @Status Bit

Select @Filname = '\\MachineName\test'
Exec master..sp_MSget_file_existence @Filname, @Status OUTPUT
If @@Error <> 0 Select @Status = 0

If @Status = 0
Begin
Print 'File not found'
End
Else
Begin
Print 'File found'
End
Go to Top of Page
   

- Advertisement -