Using T-SQL to Query a File System Folder

前端 未结 2 1108
礼貌的吻别
礼貌的吻别 2021-01-12 11:14

Is it possible to query a folder in TSQL, from SQL Management Studio, and return a list of file names? If so, how?

2条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-12 11:17

    You can use xp_cmdshell.

    Example:

    EXECUTE master.dbo.xp_cmdshell 'DIR "C:\YourDirectory\" /A-D /B'
    

    There's a good, full example with more options here.

提交回复
热议问题