USE Master
GO
declare @MyTable as Varchar(10)
declare @sql as Varchar(500)
declare MyCursor cursor for
SELECT name
FROM sys.Databases
where name like 'PDL%'
Open MyCursor
Fetch next from MyCursor into @MyTable
while @@FETCH_STATUS = 0
Begin
set @sql = ' use ' + @MyTable +
' SELECT Table_catalog,table_schema,table_name,table_type FROM information_schema.Tables where TABLE_SCHEMA <> ''dbo'''
exec(@SQL)
Fetch next from MyCursor into @MyTable
End
close MyCursor
deallocate MyCursor
沒有留言:
張貼留言