Using sp_msforeachtable and sp_helpstats

  • Hello, I would like to use sp_msforeachtable to execute sp_helpstats on each table in a database.

    This does not seem to work. Has anyone had success with this?

    use MyDb

    go

    sp_msforeachtable "print 'Table Name:? ' EXEC sp_helpstats '? ', 'STATS'"

    go

    It complains that the object does not exist.

    Thank you. 🙂

    Best Regards,

    ~David

  • As long as you output restults to text, this should work.

    sp_msforeachtable 'PRINT ''Table Name: ?''; EXEC sp_helpstats ''?'''

  • Ken, this works. Thank you very much!

    Best Regards,

    ~David

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply