DECLARE @SQL NVARCHAR(max) = N'';
SELECT @SQL = @SQL + 'DBCC CHECKDB ([' + name + ']) WITH NO_INFOMSGS;'
FROM   sys.databases
WHERE  state = 0
  AND  source_database_id IS NULL
  AND  name NOT IN ('tempdb', 'model');
EXEC (@SQL);





