SQL Stored Procedures to get folder and files
SQL Stored Procedures to get folder and files There may be a time when you will need to get the file name contents from a folder for the purpose of using the information in your stored procedure. The one undocumented stored procedure on Microsoft SQL Server 2016 is master.sys.xp_dirtree that you can use. In your stored procedure, we will go ahead and create a temporary table that will store the files with their correct extension. The first thing we want to do is check whether the temporary table was left over and remove it. Usually when you close out a session temporary tables will be destroyed but it is fine to check and do house cleaning in your stored procedure. IF OBJECT_ID('tempdb..#FilesListing') IS NOT NULL DROP TABLE #FilesListing; The…