--get all user's tables获取所有的用户表

create table #tempTabelInfo

(Id  int identity(1,1) primary key not null,

DBName nvarchar(100) not null,

TableName nvarchar(100) not null

)

go

sp_msforeachdb '

use [?]

if db_id()>4

begin

insert into #tempTabelInfo select db_name() as DBName,name as TableName from sysobjects where xtype =''u'' and category<>2 

end

'select DBName,TableName from #tempTabelInfo;

go

drop table #tempTabelInfo

go