Need Help

  • Hi all,

    I have a different requirement and also i have done that but poor performance. I need Help on this.

    I need to get count of rows of a table with condition from all databases by dbname.

    Any help on this..

    Regards

    Ram

    🙂

  • Could be something similar to this:

    DECLARE @sql nvarchar(4000)

    SET @sql = 'SELECT ''?'' AS DBNAME, COUNT(*) AS CNT FROM TableName WHERE SomeField = 1'

    DECLARE @results TABLE (

    DBNAME sysname,

    CNT int

    )

    INSERT @results

    EXEC sp_MSForEachDB @sql

    SELECT *

    FROM @results

    Hope this helps

    Gianluca

    -- Gianluca Sartori

  • Ram:) (4/1/2011)


    I have a different requirement and also i have done that but poor performance.

    You could also post what you have done so far and we could try to help with performance.

    -- Gianluca Sartori

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

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