• You can use xp_cmdshell to run the DIR command.

    DECLARE @dir VARCHAR(200)

    DECLARE @cmd VARCHAR(205)

    SELECT @dir = '\\machine\dir'

    SELECT @cmd = 'DIR ' + @dir

    CREATE TABLE #directoryFiles (lineID INT, line VARCHAR(2000))

    INSERT INTO #directoryFiles(line)

    EXEC master.dbo.xp_cmdshell @cmd

    SELECT * FROM #directoryFiles

    DROP TABLE #directoryFiles

    This will list all files in a directory, you can then use SUBSTRING to parse out the filenames. Note that the lineID is useful for getting rid of unwanted header and footer lines returned by the DIR command.



    Ade

    A Freudian Slip is when you say one thing and mean your mother.
    For detail-enriched answers, ask detail-enriched questions...[/url]