1: 2: 3: 4: 5:
EXEC sp_MSforeachdb ' DECLARE @TestTable TABLE (DBNAME varchar(200), TableName varchar(200)) INSERT INTO @TestTable SELECT DISTINCT ''?'' DBNAME , name TableName FROM [?].sys.all_objects where type = ''u'' SELECT * FROM @TestTable '