How to Use xp_dirtree to List All Files in a Folder

UPDATED — Dec 31, 2012 — Be sure to read Part 2 of this post discussing xp_dirtree. Last week I blogged about how to use an undocumented stored procedures to create folders.  This week we need to do the opposite.  We need to get a list of all files from a subfolder in order to process them.  In order to do that, we’ll use another undocumented extended stored procedure; master.sys.xp_dirtree.  This stored procedure will display a list of every folder, every subfolder, and every file for path you give it. Xp_dirtree has three parameters: directory – This is the directory … Continue reading How to Use xp_dirtree to List All Files in a Folder