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.

  • Jeff Moden (8/26/2016)


    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

    ;

    Looks more elegant to me.

    Gaz

    -- Stop your grinnin' and drop your linen...they're everywhere!!!