Home Forums Programming Powershell Got what I need, but perhaps a more elegant solution is out there. Looping through SQL filegroups to get Maxsize. RE: Got what I need, but perhaps a more elegant solution is out there. Looping through SQL filegroups to get Maxsize.

  • I guess I don't understand why anyone would use PoSh for such a thing when it's so easy to do in SQL Server itself. This also covers any NDF files you may have.

    SELECT DBName = DB_NAME(database_id)

    ,LogicalName = name

    ,MaxSize = CASE WHEN max_size >= 0 THEN CAST(max_size/128 AS VARCHAR(20))+' MB' ELSE 'Unlimited' END

    FROM sys.master_files

    WHERE database_id > 4 AND type_desc = 'ROWS'

    ORDER BY DBName,LogicalName

    ;

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)