In the Fragmentation section when it instructs to:
DECLARE @DatabaseName sysname
SET @DatabaseName = 'mydatabase' --use your own database name
The uses it:
FROM sys.dm_db_index_physical_stats(DB_ID(@DatabaseName), NULL, NULL, NULL, 'Sampled') ips
The query only actually works from the current database so there is no need to "DECLARE @DatabaseName sysname" just use DB_ID() with no parameter:
FROM sys.dm_db_index_physical_stats(DB_ID(), NULL, NULL, NULL, 'Sampled') ips