xp_getfiledetails

  • create table #fileexists (

    Altname varchar(32),

    Size varchar(12),

    Creatdt varchar(13),

    Creatti varchar(13),

    LstWridt varchar(17),

    LstWriti varchar(17),

    LstAccdt varchar(18),

    LstAccti varchar(18),

    Attrib varchar(11)

    )

    -- Insert into the temporary table

    Insert into #fileexists exec master..xp_getfiledetails 'D:\Data\Comm.txt'

    If I run it its gives me back a result. But If I change it to exec master..xp_getfiledetails 'D:\Data\*.txt'

    it gives me an error

    Msg 22004, Level 16, State 1, Procedure xp_getfiledetails, Line 22

    The system cannot find the file specified.

    Is there a way of getting the alternatename as it is always null...

    What other extended procs can one use to capture directory contents

    and count all the files

  • If xp_cmdshell is enabled on your server you can use it to get a list of files from your directory first and storwe the names in a (temp) table.

    Something like this:

    CREATE TABLE #files (FileName NVARCHAR(255))

    GO

    INSERT INTO #files

    EXEC master..xp_cmdshell 'dir d:\ /B'

    GO

    SELECT * FROM #files

    But don't forget, xp_cmdshell is by default disabled in SQL 2005

    [font="Verdana"]Markus Bohse[/font]

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

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