Fetch Physical filenames in SQL Database

  • Hi Team,

    I have a folder with 1000 text(.txt) files in it.

    I want to insert the filenames into a table in sql server.

    Is it possible in SQL Server 2008..?

  • Here's an example:

    declare @FileList table

    (

    SubDir varchar(500)

    ,Depth int

    ,IsFile int

    );

    insert @FileList

    (SubDir

    ,Depth

    ,IsFile

    )

    exec master.dbo.xp_dirtree "c:\users", 1, 1

    select *

    from @FileList fl

    The absence of evidence is not evidence of absence
    - Martin Rees
    The absence of consumable DDL, sample data and desired results is, however, evidence of the absence of my response
    - Phil Parkin

  • Thank you, Thank you.

    Its working good.

  • Hi Team,

    How to get the details from another server which does not have sql server installed on that machine.

  • Trying to access using below statement, but no results.

    exec master.dbo.xp_dirtree "\\113.218.216.127\New folder\txt\", 1, 1

    Please help to acccess the files names from different machine.

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

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