Call now: 252-767-6166  
Oracle Training Oracle Support Development Oracle Apps

 
 Home
 E-mail Us
 Oracle Articles
New Oracle Articles


 Oracle Training
 Oracle Tips

 Oracle Forum
 Class Catalog


 Remote DBA
 Oracle Tuning
 Emergency 911
 RAC Support
 Apps Support
 Analysis
 Design
 Implementation
 Oracle Support


 SQL Tuning
 Security

 Oracle UNIX
 Oracle Linux
 Monitoring
 Remote s
upport
 Remote plans
 Remote
services
 Application Server

 Applications
 Oracle Forms
 Oracle Portal
 App Upgrades
 SQL Server
 Oracle Concepts
 Software Support

 Remote S
upport  
 Development  

 Implementation


 Consulting Staff
 Consulting Prices
 Help Wanted!

 


 Oracle Posters
 Oracle Books

 Oracle Scripts
 Ion
 Excel-DB  

Don Burleson Blog 


 

 

 


 

 

 

 
 

Script to display SQL Server files for autogrowth

SQL Server Tips by Donald Burleson


This is one of the many SQL Server Windows scripts to display storage filegroups from the book "High Performance SQL Server DBA".

From filegroups , the DBA can drill down to the individual file level with the up_bn_storage_files   procedure in SQL Server 2000 and above.  This script will reveal whether any files are not enabled for autogrowth and if any file has a maximum file limit imposed. 

 See code depot for full script

 
IF OBJECT_ID('dbo.up_bn_storage_files') IS NOT NULL
BEGIN
    DROP PROCEDURE dbo.up_bn_storage_files
    IF OBJECT_ID('dbo.up_bn_storage_files') IS NOT NULL
        PRINT '<<< FAILED DROPPING PROCEDURE dbo.up_bn_storage_files >>>'
    ELSE
        PRINT '<<< DROPPED PROCEDURE dbo.up_bn_storage_files >>>'
END
go
CREATE PROCEDURE up_bn_storage_files
AS
    set nocount on
   
    declare @db_name sysname,
            @testamt float

    create table #file_info
        (dbname sysname NULL,
         groupid int NULL,
         groupname sysname NULL,
         logicname nchar(128) NULL,
         filename nchar(260) NULL,
         filestatus int NULL,  /* to get data or log */
         file_size float NULL,
         file_max_size float NULL,
         file_growth_size float NULL)

    declare
        db_cursor cursor for
            select
                name
            from
                master..sysdatabases
            where
                databasepropertyex(name,'status') not in
                ('SUSPECT', 'OFFLINE', 'RESTORING', 'RECOVERING') and
                has_dbaccess(name) = 1

    open db_cursor
    fetch
        db_cursor
    into
        @db_name
       
    while @@fetch_status = 0
    begin
        insert
            into #file_info
            (dbname,
             groupid,
             groupname,
             logicname,
             filename,
             filestatus,
             file_size,
             file_max_size,
             file_growth_size)
        exec
            ('use [' + @db_name + ']
             select
                db_name = db_name(),
                b.groupid,
                a.groupname,
                b.name,
                b.filename,
                b.status,
                b.size,
                b.maxsize,
                b.growth
             from
See code depot for full script

    select 
        dbname,
        logicname,
        file_group = case groupname
            when NULL then 'LOG'
            else groupname
            end,
        filename,
        size_in_mb = convert(decimal(17,2),((file_size * 8) / 1024)),
        can_grow = case file_growth_size
            when 0 then 'NO'
            else 'YES'
            end,
        growth_amount = case (filestatus&0x100000)
            when 0x100000 then convert(varchar(18),file_growth_size) + '%'
            else convert(varchar(18),(file_growth_size * 8) / 1024) + ' MB'
            end,
        max_file_size_mb = case(file_max_size)
            when -1 then 'UNLIMITED'
            else convert(varchar(18),((file_max_size * 8) / 1024))
            end
    from
        #file_info
See code depot for full script
go
IF OBJECT_ID('up_bn_storage_files') IS NOT NULL
    PRINT '<<< CREATED PROCEDURE up_bn_storage_files >>>'
ELSE
    PRINT '<<< FAILED CREATING PROCEDURE up_bn_storage_files >>>'
go

 

Figure 5.3 is a representation of the demographic information for the database and log files.

 This is one of the many SQL Server Windows scripts to display storage filegroups from the book "High Performance SQL Server DBA".


 

 

��  
 
 
Oracle Training at Sea
 
 
 
 
oracle dba poster
 

 
Follow us on Twitter 
 
Oracle performance tuning software 
 
Oracle Linux poster
 
 
 

 

Burleson is the American Team

Note: This Oracle documentation was created as a support and Oracle training reference for use by our DBA performance tuning consulting professionals.  Feel free to ask questions on our Oracle forum.

Verify experience! Anyone considering using the services of an Oracle support expert should independently investigate their credentials and experience, and not rely on advertisements and self-proclaimed expertise. All legitimate Oracle experts publish their Oracle qualifications.

Errata?  Oracle technology is changing and we strive to update our BC Oracle support information.  If you find an error or have a suggestion for improving our content, we would appreciate your feedback.  Just  e-mail:  

and include the URL for the page.


                    









Burleson Consulting

The Oracle of Database Support

Oracle Performance Tuning

Remote DBA Services


 

Copyright © 1996 -  2020

All rights reserved by Burleson

Oracle ® is the registered trademark of Oracle Corporation.