database size

  • Hi All,

    Could any one give me T-sql script for finding the database size for all databases which will be run on multiple servers.

    Thanks to All,

    rekha..

  • gsuvarnarekha (2/28/2011)


    Hi All,

    Could any one give me T-sql script for finding the database size for all databases which will be run on multiple servers.

    Thanks to All,

    rekha..

    Creat a linked server.Try to write a loop st. and use the sysaltfiles or sh_helpdb.

    Better, If you have 2008 use the centralized server.

    Muthukkumaran Kaliyamoorthy
    https://www.sqlserverblogforum.com/

  • Hi Muthukkumaran,

    Thanks for quick response...could you give me that script having loop for all databases which gives database name and database size.

    Thanks

    Rekha

  • Plenty of ways to skin a cat...

    Have a play with sp_MSForeachdb and sys.database_files.

    Carlton.

  • Hi,

    Actually i want to use the below script for giving the datails of database name and size for all databases..

    SELECT DB_NAME(database_id) AS DatabaseName,

    Name AS Logical_Name,

    Physical_Name, (size*8)/1024 SizeMB

    FROM sys.master_files

    so what my question is for executing the above query what previleges user want?

    Thanks

    Rekha

  • Go google..

    The minimum permissions that are required to see the corresponding row are CREATE DATABASE, ALTER ANY DATABASE, or VIEW ANY DEFINITION.

    Muthukkumaran Kaliyamoorthy
    https://www.sqlserverblogforum.com/

  • Hi,

    Is any problem for user having the public role?

    Thanks

    Rekha

  • gsuvarnarekha (2/28/2011)


    Hi,

    Is any problem for user having the public role?

    Thanks

    Rekha

    Rekha

    Public role couldn't have permision to view that table.

    Give the grant VIEW ANY DEFINITION to public role.

    Muthukkumaran Kaliyamoorthy
    https://www.sqlserverblogforum.com/

  • Thanks

  • muthukkumaran (2/28/2011)


    gsuvarnarekha (2/28/2011)


    Hi,

    Is any problem for user having the public role?

    Thanks

    Rekha

    Rekha

    Public role couldn't have permision to view that table.

    Give the grant VIEW ANY DEFINITION to public role.

    I don't know what the correct alternative answer might be but granting the public role to VIEW ANY DEFINITION just doesn't seem right to me.

    --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)

  • Jeff you are right.

    I think the alternative way is create a sperate user for the application and give necessary rights to the user.

    Muthukkumaran Kaliyamoorthy
    https://www.sqlserverblogforum.com/

  • Try this script

    create table #db

    (DBNAME varchar(50),

    Size float,

    remarks varchar(4))

    GO

    insert into #db

    exec sp_databases

    select DBNAME, Size/1024 as SizeMB from #db

    order by SizeMB desc

    drop table #db

  • sp_helpdb

  • sp_helpdb

Viewing 14 posts - 1 through 13 (of 13 total)

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