Wrox Programmer Forums
|
SQL Server 2000 General discussion of Microsoft SQL Server -- for topics that don't fit in one of the more specific SQL Server forums. version 2000 only. There's a new forum for SQL Server 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2000 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 8th, 2004, 01:12 PM
Authorized User
 
Join Date: Sep 2004
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Default Getting dB Size

I know that you can get the size of your databases with exec sp_database. What I want to do is get the size of database 'XYZ' and assign it to a variable. Is this possible?

 
Old December 9th, 2004, 05:30 AM
Friend of Wrox
 
Join Date: Jun 2004
Posts: 449
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to r_ganesh76
Default

You can use sp_Helpdb


Code:
sp_Helpdb XYZ
Regards
Ganesh
 
Old December 9th, 2004, 08:52 AM
Authorized User
 
Join Date: Jun 2004
Posts: 33
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to gadhiav Send a message via Yahoo to gadhiav
Default

You can use sp_Helpdb



sp_Helpdb XYZ


Life is not the Triumph but the Struggle
 
Old December 9th, 2004, 03:52 PM
Authorized User
 
Join Date: Sep 2004
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for the reply, this does give me the size of the dB, though what I want is something like this

declare @size int

select @size = size
from someSystemTables
where dbName = 'XYZ'

Is this possible?

 
Old December 9th, 2004, 05:07 PM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 625
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to jemacc
Default

Try this

Code:
DECLARE @SQL varchar(8000), @tbname sysname

SELECT @tbname = 'master.dbo.sysfiles'

SELECT @SQL = 'SELECT NAME, SIZE FROM ' + @tbname

EXEC(@SQL)
Jaime E. Maccou
 
Old December 10th, 2004, 06:53 AM
Friend of Wrox
 
Join Date: Sep 2004
Posts: 109
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to Anantsharma Send a message via Yahoo to Anantsharma
Default

Hi,

Try this

---------------------------------
declare @dbsize numeric ---This is the varibale
create table #tb
       (Dbname varchar(100),DBsz numeric,remarks varchar(100))

Insert into #tb exec SP_DATABASES
set @dbsize =(select DBsz from #tb where dbName='YourDbName')
select @dbsize as [Database size]
drop table #tb
---------------------------------

You can pass database name also using a variable.

Hope you got my point.

Gud luck

B. Anant
 
Old December 10th, 2004, 03:31 PM
Authorized User
 
Join Date: Sep 2004
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Fantasic, this is exactly what I want :-)

Thanks very much






Similar Threads
Thread Thread Starter Forum Replies Last Post
Size of text box depending on size of another box AstridVM BOOK: Access 2003 VBA Programmer's Reference 0 March 7th, 2007 06:24 AM
increase DB size RinoDM SQL Server 2000 1 December 7th, 2006 01:25 AM
Finding the DB Sailor.mdb of Beginning ASP DB book anna Classic ASP Databases 2 August 5th, 2006 01:13 PM
How create a DBF db and set size of a field Dormarth VB Databases Basics 2 May 30th, 2006 06:06 AM
DB Size acko SQL Server 2000 2 March 8th, 2004 05:21 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.