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
More Related Contents:
- Can anyone help me to get the query to retrieve data like below [closed]
- NOT IN vs NOT EXISTS
- Simple way to transpose columns and rows in SQL?
- Only inserting a row if it’s not already there
- Optimal way to concatenate/aggregate strings
- How can I delete using INNER JOIN with SQL Server?
- Maximum size for a SQL Server Query? IN clause? Is there a Better Approach [duplicate]
- Most efficient way in SQL Server to get date from date+time?
- Convert varchar into datetime in SQL Server
- TSQL Pivot without aggregate function
- Fastest way to perform nested bulk inserts with scope_identity() usage?
- SQL performance on LEFT OUTER JOIN vs NOT EXISTS
- Why are there gaps in my IDENTITY column values?
- Stored Procedure with optional “WHERE” parameters
- Drop all the tables, stored procedures, triggers, constraints and all the dependencies in one sql statement
- How do I perform a GROUP BY on an aliased column in SQL Server?
- How to write UPDATE SQL with Table alias in SQL Server 2008?
- SQL Server 2008- Get table constraints
- Restrict an SQL Server connection to a specific IP address
- Search for “whole word match” with SQL Server LIKE pattern
- Why are logical reads for windowed aggregate functions so high?
- Can SQL Server Express LocalDB be connected to remotely?
- SQL – Call Stored Procedure for each record
- Group All Related Records in Many to Many Relationship, SQL graph connected components
- SQL – How do I get only the numbers after the decimal?
- How to retrieve records for last 30 minutes in MS SQL?
- Group consecutive rows of same value using time spans
- Connecting to Oracle Database using Sql Server Integration Services
- Why do SQL Server Scalar-valued functions get slower?
- Executing SQL query on multiple databases