How do I list files inside a folder in SQL Server without using the xp_cmdshell
stored procedure?
Step 1 : Connect your SQL Server instance and open new query window in SSMS and enable SQLCMD mode in Query tab. Step 2: Copy and paste below query in query window. Step 3: Execute query and get all file name present in that folder.
You can use xp_dirtree
It takes three parameters:
Path of a Root Directory, Depth up to which you want to get files and folders and the last one is for showing folders only or both folders and files.
EXAMPLE: EXEC xp_dirtree 'C:\', 2, 1
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With