Users: 30k; Pages Per Session: 2.5p; Avg. Session Duration: 1:35mi
TechDevOps.com
Explore Tools
{Featuring Microsoft Technologies + Enterprise Data + Cloud Computing}



Automate DBCC UpdateUsage per select list of databases
by BF (Senior MSSQL Operations - Enterprise, Cloud, Strategy)
2018-05-18








T-SQL:

Declare @db_name varchar(250)

Declare c_db_processing Cursor For

Select [name] from master.sys.databases order by name asc

Open c_db_processing

Fetch c_db_processing INTO @db_name

While @@Fetch_Status = 0
Begin
Print('USE ['+ @db_name + '] DBCC UPDATEUSAGE (' + @db_name + ');' + '' + Char(10) + 'GO')
Fetch c_db_processing Into @db_name
End

Close c_db_processing
Deallocate c_db_processing