T-SQL To Get Count Of Records In All Tables In All Databases In SQL Server

DECLARE @DatabaseName VARCHAR(100), @MySQLCmd VARCHAR(4000)
create table #MyTempTab ([servername] nvarchar(128), [db_name] nvarchar(128), [schema] nvarchar(128), [table] nvarchar(128), 
[record_count] int)
DECLARE MyDB_Cur CURSOR FOR select [name] from sys.databases order by [name]
OPEN MyDB_Cur
FETCH NEXT FROM MyDB_Cur into @DatabaseName
WHILE @@FETCH_STATUS = 0
BEGIN        
    SET @MySQLCmd = 'USE '+@DatabaseName+';
    INSERT INTO #MYTEMPTAB
    SELECT DISTINCT @@SERVERNAME, DB_NAME(), SCHEMA_NAME(T.[SCHEMA_ID]), T.[NAME], P.[ROWS] FROM SYS.TABLES AS T INNER JOIN 
    SYS.PARTITIONS AS P ON T.[OBJECT_ID] = P.[OBJECT_ID]'
    EXEC (@MySQLCmd)    
    
FETCH NEXT FROM MyDB_Cur into @DatabaseName
END
CLOSE MyDB_Cur
DEALLOCATE MyDB_Cur
select * from #MyTempTab
drop table #MyTempTab