Here is the sql i used.
--Create the table to store file list
CREATE TABLE myFileList (FileNumber INT IDENTITY,FileName VARCHAR(256))
--Insert file list from directory to SQL Server
DECLARE @Path varchar(1024)
SET @Path = 'dir C:\ExcelFiles'
DECLARE @Command varchar(1024)
SET @Command = @Path + ' /A-D /B'
INSERT INTO myFileList
EXEC MASTER.dbo.xp_cmdshell @Command
--Check the list
SELECT * FROM myFileList
DROP TABLE myFileList
When i execute above sql, I get file not found.
I'm sure i did execute same or similar sql below and always worked.
Not sure why it isn't working now.
FYI: C:\ExcelFiles is local to workstation not on sql server and has bunch of excel files.
Maybe it's looking for something on sql server ????