need help on xp_fileexist

  • Hi Everyone,

    I want to know that in the directory Is file exist or not and I come across following,

    EXEC Master.dbo.xp_fileexist 'C:\test.txt'

    But what If file is coming in the directory on hourly bases and file name has time stamp on it.

    How can I use EXEC Master.dbo.xp_fileexist ?

    ex: TEST_DMMDDYY_THHMMSS.txt

    Thanks

  • You need the actual filename for xp_fileexist, so unless you can get the exact timestamp before checking, its not going to be possible.

    I think the way to check for a file listing is using xp_cmdshell.

    But that proc is usually locked down by most administrators.

    You may be better off writing a CLR routine, as your admin may give permissions for a your specific CLR - but not for xp_cmdshell.

  • Gosh... you don't need a CLR for this.

    EXEC xp_DirTree 'C:\',1,1

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

Viewing 3 posts - 1 through 2 (of 2 total)

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