March 16, 2008 at 10:14 am
How do you get the size of a database - (sql server 2005) using either query analyzer or one of the admin tools? Thanks...
March 16, 2008 at 10:23 am
I figured it out... it's: sp_spaceused
March 16, 2008 at 9:37 pm
Yep... also try sp_helpdb. Not as robust but will tell you the overall size. And thanks for posting even though you found your own answer.
--Jeff Moden
Change is inevitable... Change for the better is not.
March 16, 2008 at 10:36 pm
you can also get a lot more specific info using some of the standard reports available in 2005's right-click functionality (appeared in Sp1 or 2?). Things like physical space vs free space, space used by table (with index usage, etc...).
Worth a perusal if you have something in mind. Also tends to be a lot kinder on the eyes if you need to show it around.
----------------------------------------------------------------------------------
Your lack of planning does not constitute an emergency on my part...unless you're my manager...or a director and above...or a really loud-spoken end-user..All right - what was my emergency again?
March 17, 2008 at 12:45 pm
I put these queries together some time ago. Feel free to use them as you wish.
-- SQL Server 2000 only.
--
-- Author: Damon T. Wilson
-- Creation Date: 13-DEC-2006
--
-- Usage:
-- Display the Database ID, Database Name, Logical File Name,
-- MB Size on Disk, GB Size on Disk and Physical File Name
-- for all databases in this instance.
use master;
go
select
db.[dbid] as 'DB ID'
,db.[name] as 'Database Name'
,af.[name] as 'Logical Name'
--,af. as 'File Size (in 8-kilobyte (KB) pages)'
,(((CAST(af. as DECIMAL(18,4)) * 8192) /1024) /1024) as 'File Size (MB)'
,((((CAST(af. as DECIMAL(18,4)) * 8192) /1024) /1024) /1024) as 'File Size (GB)'
,af.[filename] as 'Physical Name'
from sysdatabases db
inner join sysaltfiles af
on db.dbid = af.dbid
where [fileid] in (1,2);
-- SQL Server 2005 only.
--
-- Author: Damon T. Wilson
-- Creation Date: 13-DEC-2006
--
-- Usage:
-- Display the Database ID, Database Name, Logical File Name,
-- MB Size on Disk, GB Size on Disk and Physical File Name
-- for all databases in this instance.
use master;
go
select
db.[dbid] as 'DB ID'
,db.[name] as 'Database Name'
,af.[name] as 'Logical Name'
--,af. as 'File Size (in 8-kilobyte (KB) pages)'
,(((CAST(af. as DECIMAL(18,4)) * 8192) /1024) /1024) as 'File Size (MB)'
,((((CAST(af. as DECIMAL(18,4)) * 8192) /1024) /1024) /1024) as 'File Size (GB)'
,af.[filename] as 'Physical Name'
from sys.sysdatabases db
inner join sys.sysaltfiles af
on db.dbid = af.dbid
where [fileid] in (1,2);
"Key"
MCITP: DBA, MCSE, MCTS: SQL 2005, OCP
June 11, 2009 at 8:16 pm
My favorite way to view the breakdown of the used / total space in all the files of a database is with this HTML Application. It connects to a server (you must have sysadmin rights or similar) retrieves a list of all the databases, then loops through each one and figures out the used / total space for every file and displays it.
June 11, 2009 at 9:15 pm
Heh... that chart shows a high potential for performance problems... 2Mb temp table.
--Jeff Moden
Change is inevitable... Change for the better is not.
June 11, 2009 at 9:20 pm
Jeff Moden (6/11/2009)
Heh... that chart shows a high potential for performance problems... 2Mb temp table.
[font="Verdana"]Agreed. 2mb is far too large. You shouldn't ever need a temp database larger than 16kb. :hehe:[/font]
June 30, 2009 at 7:43 pm
Yeah -- of course that's just my local express instance for testing... clearly tempdb is just *slightly* too small. hehe
July 1, 2009 at 6:17 am
Just as Jeff had said sp_helpdb is what I would have used.
Viewing 10 posts - 1 through 10 (of 10 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy