Skip to main content

Home/ MS SQL Server and Analysis Services/ T-SQL: list files in folder
Sergey Leifer

T-SQL: list files in folder - 1 views

SQL Server T-SQL

started by Sergey Leifer on 07 Aug 10
  • Sergey Leifer
     
    create table #Files (
    FullName nvarchar(255) null
    )

    insert #Files
    exec master..xp_cmdshell 'DIR C:*.csv /B /S'

    select right(FullName, patindex('%%', reverse(FullName)) - 1) as ShortFileName
    ,*
    from #Files
    where not FullName is null

    drop table #Files

To Top

Start a New Topic » « Back to the MS SQL Server and Analysis Services group