I have an sql query as show below. I would like to know how I can loop through a list of users and run this query per user.
I have code connecting to a single db but have never done so using multiple dbs.
Any help greatly appreciated.
SELECT A.ArchiveName, COUNT(S.IdTransaction) "Num. Items Archived", SUM(S.ItemSize)/1024 "Archived Items Size (MB)", SUM(SP.OriginalSize)/1024/1024 "Original Email Size (MB)" FROM EVDirectory.dbo.Archive A, EVDirectory.dbo.Root R, EVVaultStore.dbo.ArchivePoint AP, EVVaultStore.dbo.Saveset S, EVVaultStore.dbo.SavesetProperty SP WHERE S.SavesetIdentity = SP.SavesetIdentity AND S.ArchivePointIdentity = AP.ArchivePointIdentity AND AP.ArchivePointId = R.VaultEntryId AND R.RootIdentity = A.RootIdentity AND A.ArchiveName = 'username' GROUP BY A.ArchiveName