• Shaz I made a small change to your script to work with my databases. I have a couple that have a space in the file name. No major change, just added the few brakets to the ? below.

    set @Command= 'if not exists (select * from #systemdbs where name = ''[?]'') begin '+char(13)+

    +'use [?] ; insert #dbusersbuffer exec sp_helpuser'+char(13)

    +'insert #dbusers select ''?'', * from #dbusersbuffer'+char(13)

    +'truncate table #dbusersbuffer'+char(13)

    +'end'