I am trying to get list of file in a directory using sql server path having more then 128
character is not working.
- DECLARE
- @FilePath varchar(256)='D:\...',
-
- @SourceFiles varchar(100)='Test123456789*.txt',
- @Query varchar(1000)
-
- If Object_Id('tempdb.dbo.#FirstTable') Is NULL
- CREATE TABLE #FirstTable (Name varchar(256))
-
- SET QUOTED_IDENTIFIER ON
- SET @Query ='master.dbo.xp_cmdshell "dir '+ @FilePath + '\' + @SourceFiles +' /b"'
-
- INSERT #FirstTable exec (@Query)
- select * from #FirstTable
-
- truncate table #FirstTable