/*
09.10.2024, TSC
*/
IF OBJECT_ID('tempdb..#fstream')IS NOT NULL BEGIN;
    DROP TABLE #fstream;
END;

CREATE TABLE #fstream (
    [db_name] VARCHAR(255) NOT NULL 
    ,table_schema VARCHAR(99) NOT NULL
    ,table_name VARCHAR(99) NOT NULL 
    ,column_name VARCHAR(255) NOT NULL 
)

DECLARE @tpl VARCHAR(MAX) ='
USE ?

INSERT INTO [#fstream] (
    [db_name],
    [table_schema],
    [table_name],
    [column_name]
)
SELECT
    DB_NAME() AS [db_name]
    ,SCHEMA_NAME(t.[schema_id] ) AS table_schema
    , t.[name] as table_name
    , c.[name] AS column_name
FROM sys.[columns] c
    JOIN sys.[tables] t ON t.[object_id] = c.[object_id]
WHERE [c].[is_filestream] = 1
'

EXEC [sys].[sp_MSforeachdb] @command1 = @tpl

SELECT * 
FROM [#fstream]
ORDER BY [db_name]