this was an order of magnitude faster: 8 minutes to create a text file to disk, then 20 seconds to bulk insert into a table
using the /b command, it was only 1 minute 11 secs to create the file to disk.
CREATE TABLE #Results (txtResult varchar(2000) NULL)
INSERT INTO #Results (txtResult)
EXEC master.dbo.xp_cmdshell 'DIR "C:\PROGRAM FILES\*.*" /b s >C:\contents.txt'
BULK INSERT #Results FROM 'C:\contents.txt'
WITH (
DATAFILETYPE = 'char',
FIELDTERMINATOR = ',',
ROWTERMINATOR = '',
FIRSTROW = 1
)
SELECT * FROM #Results
Lowell