Wednesday, March 4, 2009

Import directory structure into SQL Server database

 

Import directory structure into SQL Server database

In order to import the directory structure in a machine from the given root directory and recursively need to import all files under each directory also.

You can run a dos 'DIR' command using XP_CMDSHELL and can store the value to a temp table. Then you can process the records and probably format them a little. For example:

Code Snippet

CREATE TABLE #dir (OUTPUT VARCHAR(MAX))

INSERT INTO #dir EXECUTE xp_cmdshell 'dir c:'

Published Wednesday, March 04, 2009 10:24 AM by sreekarm

Cool Things about SQL Server : Import directory structure into SQL Server database

No comments:

Blog Archive