Is it possible to query a folder in TSQL, from SQL Management Studio, and return a list of file names? If so, how?
Select(s => new SqlString(s)); } public static void GetFiles_FillRow(object obj,out SqlString filePath) { filePath = (SqlString)obj; } }; And your SQL query. use MyDb select * From GetFiles('C:\Temp\'); Be aware though, your database needs to have CLR Assembly functionaliy enabled using the following SQL Command.
You have two native options for finding out where the SQL server stores its database files: either right-click on the instance name in SQL Server Management Studio (SSMS) and navigate to the 'Database Settings' tab, or use a T-SQL query.
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.
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