Select
Name = Substring(O.Name, 1, 30),
Rows = Convert(Char(12), I.Rows)
From
SysObjects O,
SysIndexes I,
Master.dbo.spt_values D
Where
I.ID = O.ID And
I.Indid < 2 And
(O.Type = 'U' Or O.Name = 'syslogs') And
D.Number = 1 And
D.Type = 'E'
Order By
Name
I know you have already got a solution to your original question but if you need to do things like this again you can use the stored procedure sp_MSforeachtable
eg
sp_MSforeachtable 'select count(*) "?" from ?'
this will do the same as the code you used previously.
There is also one called sp_MSforeachdb to allow you to perform commands against all databases.
These two stored procedures are not particularly well documented unfortunately.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.