try this...
declare @command1 varchar(8000)
select @command1 =
'
IF ''@'' ''master'' AND ''@'' ''model'' AND ''@'' ''msdb'' AND ''@'' ''tempdb''
begin
use [@] execute sp_MSForEachTable ''print ''''?'''' ''
end
'
exec sp_MSforeachdb @command1, '@'
Prakash Heda
Lead DBA Team - www.sqlfeatures.com
Video sessions on Performance Tuning and SQL 2012 HA