Если безопасность не является большой проблемой, и вы можете включить xp_cmdshell в своем экземпляре sql, вы можете использовать списки каталогов командной оболочки для получения информации.Например
Declare @Dir VARCHAR(256)
DECLARE @CMD VARCHAR(256)
SET @Dir = 'C:\myImageFolder\'
SET @CMD = 'DIR "'+@DIR+'" /A /S'
CREATE TABLE #tmp
(returnval NVARCHAR(500), rownum INT IDENTITY(1,1))
-- Populate Temp Table with the contents of the outfiles directory
INSERT #tmp EXEC master..xp_cmdshell @cmd
-- Delete rows with no file information
DELETE FROM #tmp WHERE returnval IS NULL
DELETE FROM #tmp WHERE ISNUMERIC(LEFT(returnval,1))=0 AND returnval NOT LIKE '%Directory of%'
DELETE FROM #tmp WHERE returnval LIKE '%<DIR> .%'
-- Separate the output into it's proper columns
SELECT
rownum,
(SELECT TOP 1 REPLACE(returnVal, ' Directory of ','') FROM #tmp t2 WHERE t2.rownum < t.rownum AND t2.returnval LIKE ' Directory of%' ORDER BY t2.rownum DESC) Directory,
CAST(LEFT(returnval,10) AS DATETIME) AS file_date,
CASE WHEN SUBSTRING(returnval,22,17) LIKE '%<DIR>%' THEN NULL ELSE CAST(REPLACE(SUBSTRING(returnval,22,17),',','') AS NUMERIC) END AS 'size(bytes)',
RIGHT(RTRIM([returnval]),LEN(RTRIM([returnval]))-39) AS [file_name],
CASE WHEN SUBSTRING(returnval,22,17) LIKE '%<DIR>%' THEN 'Directory' ELSE 'File' END AS [Type],
CASE WHEN SUBSTRING(returnval,22,17) LIKE '%<DIR>%' THEN NULL ELSE RIGHT(rtrim([returnval]), CHARINDEX('.',REVERSE(RTRIM([returnval])))) END AS extension
FROM #tmp t
WHERE returnval NOT LIKE '%Directory of%'