querying the file system

  • Hi,

    quick question:

    how do you query the file system in t-sql to know if a file exist.

    I tried xp_cmdshell, but the problem is that my files are long file name (only the few last caracters are changing).

    Thanks,

    Erik

     

  • exec xp_fileexist @Filename, @yes output

     


    * Noel

  • are all those files in the same directory??

    are the list of files to check for all on the server, or easily transferable?

  • thanks for the quick answer!

    Remi:yep, all on the same directory, on the same server. In fact, I'm doing an automatic database restore script and I'm checking to be sure that the log file exists before actually restoring the log file.

    There is probably another way around, but this one seems to work fine!

    Erik

  • ok, My solution would be useless in this case, it was made to handle large files count, but since you have only 2 files to check you obviously don't need it.

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply