Code:
SELECT name AS DatabaseName
from master.dbo.sysdatabases
where sid <> 0x01
Now I just want to build a union like this:
Code:
select DatabaseName, name as CollectionName, oid as CollectionID
from [DB1].dbo.objects
where sclid = -1
union all
select DatabaseName, name as CollectionName, oid as CollectionID
from [db2].dbo.objects
where sclid = -1
I want the databases from the first query to loop through the variable of the [db1] [db2] with the DatabaseName column in the union.
That way I get accurate data each time it runs.
Any thoughts on how to accomplish this please?
misscrf
It is never too late to become what you could have been ~ George Eliot