Hi, try something like this and build on a sql string, I hope this helps.
DECLARE @sql VARCHAR(MAX), @db VARCHAR(255)
DECLARE c CURSOR FOR
SELECT [name] from master.dbo.sysdatabases
OPEN c
FETCH NEXT FROM c INTO @db
WHILE @@FETCH_STATUS = 0
BEGIN
SET @sql = 'Use ' + @db + SPACE(2)
SET @sql = @sql + ' SELECT t.name As TableName, i.name As IndexName FROM sys.tables t,
sys.indexes i
WHERE i.object_id = t.object_id
ORDER BY t.Name'
FETCH NEXT FROM c INTO @db END
CLOSE c
DEALLOCATE c
--PRINT @SQL
EXEC(@sql)
TJR We Came! We Saw! We Listened! We Eliminated Ambiguity and developed a system the user wanted, not what we thought they wanted. Enough Said!