Hi,
SQL2K, Win 2k.
I am trying to acquire space by deleting older records from a table.
When I ran sp_spaceused on a Table A, I got following output
Table A
rows: 145030470
reserved: 139653704 KB
data: 81832616 KB= 78GB
index_size: 23655616 KB = 22.5
unused: 34165472 KB
Afte that I had deleted around 60 million records based on certain criteria.
I thought I will get atleast 30GB free space. But when I checked in EM > task
pad, I only see around 14GB free space.
Is there anyway to get free space from the pages?
Thanks in advance
Chinna.
See BOL... DBCC Shrinkfile
"Chinna Kondaveeti" wrote:
> Hi,
> SQL2K, Win 2k.
> I am trying to acquire space by deleting older records from a table.
> When I ran sp_spaceused on a Table A, I got following output
> Table A
> rows: 145030470
> reserved: 139653704 KB
> data: 81832616 KB= 78GB
> index_size: 23655616 KB = 22.5
> unused: 34165472 KB
> Afte that I had deleted around 60 million records based on certain criteria.
> I thought I will get atleast 30GB free space. But when I checked in EM > task
> pad, I only see around 14GB free space.
> Is there anyway to get free space from the pages?
> Thanks in advance
> Chinna.
>
|||Thanks for the reply. I ran dbcc shrinkfile to get that 14GB free space. What
I am trying to say is, based on the size estimation, there should have been
more than 14GB free space. But I don't see that in the task pad view. Is
there any way to reorganize the pages/db files to get the remaining space?
Thanks in advance
Chinna.
"Wex" wrote:
[vbcol=seagreen]
> See BOL... DBCC Shrinkfile
> "Chinna Kondaveeti" wrote:
|||Does the table have a Clustered Index? If so use DBCC SHOWCONTIG to see the
level of fragmentation. You can use DBCC INDEXDEFRAG to defragment the
index. Watch out for performance drop of while defraging
"Chinna Kondaveeti" wrote:
[vbcol=seagreen]
> Thanks for the reply. I ran dbcc shrinkfile to get that 14GB free space. What
> I am trying to say is, based on the size estimation, there should have been
> more than 14GB free space. But I don't see that in the task pad view. Is
> there any way to reorganize the pages/db files to get the remaining space?
> Thanks in advance
> Chinna.
> "Wex" wrote:
|||Chinna,
Do you have text or image column? If you do then you will have issues
reclaming all the space.
Did you use truncate option or noturncate option. There is a difference in
the way these work.
"Chinna Kondaveeti" <ChinnaKondaveeti@.discussions.microsoft.com> wrote in
message news:4DA0D6E0-E353-4751-A485-817CBD4A53E7@.microsoft.com...
> Thanks for the reply. I ran dbcc shrinkfile to get that 14GB free space.
What
> I am trying to say is, based on the size estimation, there should have
been[vbcol=seagreen]
> more than 14GB free space. But I don't see that in the task pad view. Is
> there any way to reorganize the pages/db files to get the remaining space?
> Thanks in advance
> Chinna.
> "Wex" wrote:
criteria.[vbcol=seagreen]
> task
Showing posts with label space. Show all posts
Showing posts with label space. Show all posts
Sunday, February 19, 2012
How to get free space
Hi,
SQL2K, Win 2k.
I am trying to acquire space by deleting older records from a table.
When I ran sp_spaceused on a Table A, I got following output
Table A
rows: 145030470
reserved: 139653704 KB
data: 81832616 KB = 78GB
index_size: 23655616 KB = 22.5
unused: 34165472 KB
Afte that I had deleted around 60 million records based on certain criteria.
I thought I will get atleast 30GB free space. But when I checked in EM > tas
k
pad, I only see around 14GB free space.
Is there anyway to get free space from the pages?
Thanks in advance
Chinna.See BOL... DBCC Shrinkfile
"Chinna Kondaveeti" wrote:
> Hi,
> SQL2K, Win 2k.
> I am trying to acquire space by deleting older records from a table.
> When I ran sp_spaceused on a Table A, I got following output
> Table A
> rows: 145030470
> reserved: 139653704 KB
> data: 81832616 KB = 78GB
> index_size: 23655616 KB = 22.5
> unused: 34165472 KB
> Afte that I had deleted around 60 million records based on certain criteri
a.
> I thought I will get atleast 30GB free space. But when I checked in EM > t
ask
> pad, I only see around 14GB free space.
> Is there anyway to get free space from the pages?
> Thanks in advance
> Chinna.
>|||Thanks for the reply. I ran dbcc shrinkfile to get that 14GB free space. Wha
t
I am trying to say is, based on the size estimation, there should have been
more than 14GB free space. But I don't see that in the task pad view. Is
there any way to reorganize the pages/db files to get the remaining space?
Thanks in advance
Chinna.
"Wex" wrote:
[vbcol=seagreen]
> See BOL... DBCC Shrinkfile
> "Chinna Kondaveeti" wrote:
>|||Does the table have a Clustered Index? If so use DBCC SHOWCONTIG to see the
level of fragmentation. You can use DBCC INDEXDEFRAG to defragment the
index. Watch out for performance drop of while defraging
"Chinna Kondaveeti" wrote:
[vbcol=seagreen]
> Thanks for the reply. I ran dbcc shrinkfile to get that 14GB free space. W
hat
> I am trying to say is, based on the size estimation, there should have bee
n
> more than 14GB free space. But I don't see that in the task pad view. Is
> there any way to reorganize the pages/db files to get the remaining space?
> Thanks in advance
> Chinna.
> "Wex" wrote:
>|||Chinna,
Do you have text or image column? If you do then you will have issues
reclaming all the space.
Did you use truncate option or noturncate option. There is a difference in
the way these work.
"Chinna Kondaveeti" <ChinnaKondaveeti@.discussions.microsoft.com> wrote in
message news:4DA0D6E0-E353-4751-A485-817CBD4A53E7@.microsoft.com...
> Thanks for the reply. I ran dbcc shrinkfile to get that 14GB free space.
What
> I am trying to say is, based on the size estimation, there should have
been[vbcol=seagreen]
> more than 14GB free space. But I don't see that in the task pad view. Is
> there any way to reorganize the pages/db files to get the remaining space?
> Thanks in advance
> Chinna.
> "Wex" wrote:
>
criteria.[vbcol=seagreen]
> task
SQL2K, Win 2k.
I am trying to acquire space by deleting older records from a table.
When I ran sp_spaceused on a Table A, I got following output
Table A
rows: 145030470
reserved: 139653704 KB
data: 81832616 KB = 78GB
index_size: 23655616 KB = 22.5
unused: 34165472 KB
Afte that I had deleted around 60 million records based on certain criteria.
I thought I will get atleast 30GB free space. But when I checked in EM > tas
k
pad, I only see around 14GB free space.
Is there anyway to get free space from the pages?
Thanks in advance
Chinna.See BOL... DBCC Shrinkfile
"Chinna Kondaveeti" wrote:
> Hi,
> SQL2K, Win 2k.
> I am trying to acquire space by deleting older records from a table.
> When I ran sp_spaceused on a Table A, I got following output
> Table A
> rows: 145030470
> reserved: 139653704 KB
> data: 81832616 KB = 78GB
> index_size: 23655616 KB = 22.5
> unused: 34165472 KB
> Afte that I had deleted around 60 million records based on certain criteri
a.
> I thought I will get atleast 30GB free space. But when I checked in EM > t
ask
> pad, I only see around 14GB free space.
> Is there anyway to get free space from the pages?
> Thanks in advance
> Chinna.
>|||Thanks for the reply. I ran dbcc shrinkfile to get that 14GB free space. Wha
t
I am trying to say is, based on the size estimation, there should have been
more than 14GB free space. But I don't see that in the task pad view. Is
there any way to reorganize the pages/db files to get the remaining space?
Thanks in advance
Chinna.
"Wex" wrote:
[vbcol=seagreen]
> See BOL... DBCC Shrinkfile
> "Chinna Kondaveeti" wrote:
>|||Does the table have a Clustered Index? If so use DBCC SHOWCONTIG to see the
level of fragmentation. You can use DBCC INDEXDEFRAG to defragment the
index. Watch out for performance drop of while defraging
"Chinna Kondaveeti" wrote:
[vbcol=seagreen]
> Thanks for the reply. I ran dbcc shrinkfile to get that 14GB free space. W
hat
> I am trying to say is, based on the size estimation, there should have bee
n
> more than 14GB free space. But I don't see that in the task pad view. Is
> there any way to reorganize the pages/db files to get the remaining space?
> Thanks in advance
> Chinna.
> "Wex" wrote:
>|||Chinna,
Do you have text or image column? If you do then you will have issues
reclaming all the space.
Did you use truncate option or noturncate option. There is a difference in
the way these work.
"Chinna Kondaveeti" <ChinnaKondaveeti@.discussions.microsoft.com> wrote in
message news:4DA0D6E0-E353-4751-A485-817CBD4A53E7@.microsoft.com...
> Thanks for the reply. I ran dbcc shrinkfile to get that 14GB free space.
What
> I am trying to say is, based on the size estimation, there should have
been[vbcol=seagreen]
> more than 14GB free space. But I don't see that in the task pad view. Is
> there any way to reorganize the pages/db files to get the remaining space?
> Thanks in advance
> Chinna.
> "Wex" wrote:
>
criteria.[vbcol=seagreen]
> task
How to get free space
Hi,
SQL2K, Win 2k.
I am trying to acquire space by deleting older records from a table.
When I ran sp_spaceused on a Table A, I got following output
Table A
rows: 145030470
reserved: 139653704 KB
data: 81832616 KB = 78GB
index_size: 23655616 KB = 22.5
unused: 34165472 KB
Afte that I had deleted around 60 million records based on certain criteria.
I thought I will get atleast 30GB free space. But when I checked in EM > task
pad, I only see around 14GB free space.
Is there anyway to get free space from the pages?
Thanks in advance
Chinna.See BOL... DBCC Shrinkfile
"Chinna Kondaveeti" wrote:
> Hi,
> SQL2K, Win 2k.
> I am trying to acquire space by deleting older records from a table.
> When I ran sp_spaceused on a Table A, I got following output
> Table A
> rows: 145030470
> reserved: 139653704 KB
> data: 81832616 KB = 78GB
> index_size: 23655616 KB = 22.5
> unused: 34165472 KB
> Afte that I had deleted around 60 million records based on certain criteria.
> I thought I will get atleast 30GB free space. But when I checked in EM > task
> pad, I only see around 14GB free space.
> Is there anyway to get free space from the pages?
> Thanks in advance
> Chinna.
>|||Thanks for the reply. I ran dbcc shrinkfile to get that 14GB free space. What
I am trying to say is, based on the size estimation, there should have been
more than 14GB free space. But I don't see that in the task pad view. Is
there any way to reorganize the pages/db files to get the remaining space?
Thanks in advance
Chinna.
"Wex" wrote:
> See BOL... DBCC Shrinkfile
> "Chinna Kondaveeti" wrote:
> > Hi,
> > SQL2K, Win 2k.
> > I am trying to acquire space by deleting older records from a table.
> > When I ran sp_spaceused on a Table A, I got following output
> >
> > Table A
> > rows: 145030470
> > reserved: 139653704 KB
> > data: 81832616 KB = 78GB
> > index_size: 23655616 KB = 22.5
> > unused: 34165472 KB
> >
> > Afte that I had deleted around 60 million records based on certain criteria.
> > I thought I will get atleast 30GB free space. But when I checked in EM > task
> > pad, I only see around 14GB free space.
> >
> > Is there anyway to get free space from the pages?
> >
> > Thanks in advance
> > Chinna.
> >
> >|||Does the table have a Clustered Index? If so use DBCC SHOWCONTIG to see the
level of fragmentation. You can use DBCC INDEXDEFRAG to defragment the
index. Watch out for performance drop of while defraging
"Chinna Kondaveeti" wrote:
> Thanks for the reply. I ran dbcc shrinkfile to get that 14GB free space. What
> I am trying to say is, based on the size estimation, there should have been
> more than 14GB free space. But I don't see that in the task pad view. Is
> there any way to reorganize the pages/db files to get the remaining space?
> Thanks in advance
> Chinna.
> "Wex" wrote:
> > See BOL... DBCC Shrinkfile
> >
> > "Chinna Kondaveeti" wrote:
> >
> > > Hi,
> > > SQL2K, Win 2k.
> > > I am trying to acquire space by deleting older records from a table.
> > > When I ran sp_spaceused on a Table A, I got following output
> > >
> > > Table A
> > > rows: 145030470
> > > reserved: 139653704 KB
> > > data: 81832616 KB = 78GB
> > > index_size: 23655616 KB = 22.5
> > > unused: 34165472 KB
> > >
> > > Afte that I had deleted around 60 million records based on certain criteria.
> > > I thought I will get atleast 30GB free space. But when I checked in EM > task
> > > pad, I only see around 14GB free space.
> > >
> > > Is there anyway to get free space from the pages?
> > >
> > > Thanks in advance
> > > Chinna.
> > >
> > >|||Chinna,
Do you have text or image column? If you do then you will have issues
reclaming all the space.
Did you use truncate option or noturncate option. There is a difference in
the way these work.
"Chinna Kondaveeti" <ChinnaKondaveeti@.discussions.microsoft.com> wrote in
message news:4DA0D6E0-E353-4751-A485-817CBD4A53E7@.microsoft.com...
> Thanks for the reply. I ran dbcc shrinkfile to get that 14GB free space.
What
> I am trying to say is, based on the size estimation, there should have
been
> more than 14GB free space. But I don't see that in the task pad view. Is
> there any way to reorganize the pages/db files to get the remaining space?
> Thanks in advance
> Chinna.
> "Wex" wrote:
> > See BOL... DBCC Shrinkfile
> >
> > "Chinna Kondaveeti" wrote:
> >
> > > Hi,
> > > SQL2K, Win 2k.
> > > I am trying to acquire space by deleting older records from a table.
> > > When I ran sp_spaceused on a Table A, I got following output
> > >
> > > Table A
> > > rows: 145030470
> > > reserved: 139653704 KB
> > > data: 81832616 KB = 78GB
> > > index_size: 23655616 KB = 22.5
> > > unused: 34165472 KB
> > >
> > > Afte that I had deleted around 60 million records based on certain
criteria.
> > > I thought I will get atleast 30GB free space. But when I checked in EM
> task
> > > pad, I only see around 14GB free space.
> > >
> > > Is there anyway to get free space from the pages?
> > >
> > > Thanks in advance
> > > Chinna.
> > >
> > >
SQL2K, Win 2k.
I am trying to acquire space by deleting older records from a table.
When I ran sp_spaceused on a Table A, I got following output
Table A
rows: 145030470
reserved: 139653704 KB
data: 81832616 KB = 78GB
index_size: 23655616 KB = 22.5
unused: 34165472 KB
Afte that I had deleted around 60 million records based on certain criteria.
I thought I will get atleast 30GB free space. But when I checked in EM > task
pad, I only see around 14GB free space.
Is there anyway to get free space from the pages?
Thanks in advance
Chinna.See BOL... DBCC Shrinkfile
"Chinna Kondaveeti" wrote:
> Hi,
> SQL2K, Win 2k.
> I am trying to acquire space by deleting older records from a table.
> When I ran sp_spaceused on a Table A, I got following output
> Table A
> rows: 145030470
> reserved: 139653704 KB
> data: 81832616 KB = 78GB
> index_size: 23655616 KB = 22.5
> unused: 34165472 KB
> Afte that I had deleted around 60 million records based on certain criteria.
> I thought I will get atleast 30GB free space. But when I checked in EM > task
> pad, I only see around 14GB free space.
> Is there anyway to get free space from the pages?
> Thanks in advance
> Chinna.
>|||Thanks for the reply. I ran dbcc shrinkfile to get that 14GB free space. What
I am trying to say is, based on the size estimation, there should have been
more than 14GB free space. But I don't see that in the task pad view. Is
there any way to reorganize the pages/db files to get the remaining space?
Thanks in advance
Chinna.
"Wex" wrote:
> See BOL... DBCC Shrinkfile
> "Chinna Kondaveeti" wrote:
> > Hi,
> > SQL2K, Win 2k.
> > I am trying to acquire space by deleting older records from a table.
> > When I ran sp_spaceused on a Table A, I got following output
> >
> > Table A
> > rows: 145030470
> > reserved: 139653704 KB
> > data: 81832616 KB = 78GB
> > index_size: 23655616 KB = 22.5
> > unused: 34165472 KB
> >
> > Afte that I had deleted around 60 million records based on certain criteria.
> > I thought I will get atleast 30GB free space. But when I checked in EM > task
> > pad, I only see around 14GB free space.
> >
> > Is there anyway to get free space from the pages?
> >
> > Thanks in advance
> > Chinna.
> >
> >|||Does the table have a Clustered Index? If so use DBCC SHOWCONTIG to see the
level of fragmentation. You can use DBCC INDEXDEFRAG to defragment the
index. Watch out for performance drop of while defraging
"Chinna Kondaveeti" wrote:
> Thanks for the reply. I ran dbcc shrinkfile to get that 14GB free space. What
> I am trying to say is, based on the size estimation, there should have been
> more than 14GB free space. But I don't see that in the task pad view. Is
> there any way to reorganize the pages/db files to get the remaining space?
> Thanks in advance
> Chinna.
> "Wex" wrote:
> > See BOL... DBCC Shrinkfile
> >
> > "Chinna Kondaveeti" wrote:
> >
> > > Hi,
> > > SQL2K, Win 2k.
> > > I am trying to acquire space by deleting older records from a table.
> > > When I ran sp_spaceused on a Table A, I got following output
> > >
> > > Table A
> > > rows: 145030470
> > > reserved: 139653704 KB
> > > data: 81832616 KB = 78GB
> > > index_size: 23655616 KB = 22.5
> > > unused: 34165472 KB
> > >
> > > Afte that I had deleted around 60 million records based on certain criteria.
> > > I thought I will get atleast 30GB free space. But when I checked in EM > task
> > > pad, I only see around 14GB free space.
> > >
> > > Is there anyway to get free space from the pages?
> > >
> > > Thanks in advance
> > > Chinna.
> > >
> > >|||Chinna,
Do you have text or image column? If you do then you will have issues
reclaming all the space.
Did you use truncate option or noturncate option. There is a difference in
the way these work.
"Chinna Kondaveeti" <ChinnaKondaveeti@.discussions.microsoft.com> wrote in
message news:4DA0D6E0-E353-4751-A485-817CBD4A53E7@.microsoft.com...
> Thanks for the reply. I ran dbcc shrinkfile to get that 14GB free space.
What
> I am trying to say is, based on the size estimation, there should have
been
> more than 14GB free space. But I don't see that in the task pad view. Is
> there any way to reorganize the pages/db files to get the remaining space?
> Thanks in advance
> Chinna.
> "Wex" wrote:
> > See BOL... DBCC Shrinkfile
> >
> > "Chinna Kondaveeti" wrote:
> >
> > > Hi,
> > > SQL2K, Win 2k.
> > > I am trying to acquire space by deleting older records from a table.
> > > When I ran sp_spaceused on a Table A, I got following output
> > >
> > > Table A
> > > rows: 145030470
> > > reserved: 139653704 KB
> > > data: 81832616 KB = 78GB
> > > index_size: 23655616 KB = 22.5
> > > unused: 34165472 KB
> > >
> > > Afte that I had deleted around 60 million records based on certain
criteria.
> > > I thought I will get atleast 30GB free space. But when I checked in EM
> task
> > > pad, I only see around 14GB free space.
> > >
> > > Is there anyway to get free space from the pages?
> > >
> > > Thanks in advance
> > > Chinna.
> > >
> > >
how to get disk total space info?
hi all,
I know that master..xp_fixeddrives can give you the free space info for each
drive on your sql server.
but is there any proc that can return the total disk space?
also, anyone know how to see the code inside of master..xp_fixeddrives?
many thanks!!
JJI don;t knoiw of any way for SQL t odo that... But...
Don't you know how big the disks are ?
These values will not change often.
Create a table and put this data in it...
"JJ Wang" wrote:
> hi all,
> I know that master..xp_fixeddrives can give you the free space info for ea
ch
> drive on your sql server.
> but is there any proc that can return the total disk space?
> also, anyone know how to see the code inside of master..xp_fixeddrives?
> many thanks!!
> JJ|||xp_fixeddrives is an extended stored proc. written in C/C++ and compiled.
It most likely calls the GetDiskFreeSpaceEx API function to get the free
space. You could always write your own extended stored proc to make the
same call, but utilize the other information returned like total disk size.
Here's more info. on that:
http://support.microsoft.com/defaul...b;en-us;231497.
It might be easier just to do it from your client app - most languages have
easier ways to get at this particular info., and I think I read that SQL
2005 will also offer easier methods to access this - but someone else will
need to give you specifics on that.
"JJ Wang" <JJ Wang@.discussions.microsoft.com> wrote in message
news:B388A868-9058-45D9-A99F-38BD00B8B0B4@.microsoft.com...
> hi all,
> I know that master..xp_fixeddrives can give you the free space info for
> each
> drive on your sql server.
> but is there any proc that can return the total disk space?
> also, anyone know how to see the code inside of master..xp_fixeddrives?
> many thanks!!
> JJ|||CREATE FUNCTION dbo.GetDriveSize (@.driveletter CHAR(1))
/* Returns the total capacity for any drive letter */
RETURNS NUMERIC(20)
BEGIN
DECLARE @.rs INTEGER, @.fso INTEGER, @.getdrive VARCHAR(13),
@.drv INTEGER, @.drivesize VARCHAR(20)
SET @.getdrive = 'GetDrive("' + @.driveletter + '")'
EXEC @.rs = sp_OACreate 'Scripting.FileSystemObject', @.fso OUTPUT
IF @.rs = 0
EXEC @.rs = sp_OAMethod @.fso, @.getdrive, @.drv OUTPUT
IF @.rs = 0
EXEC @.rs = sp_OAGetProperty @.drv,'TotalSize', @.drivesize OUTPUT
IF @.rs<> 0
SET @.drivesize = NULL
EXEC sp_OADestroy @.drv
EXEC sp_OADestroy @.fso
RETURN @.drivesize
END
GO
SELECT dbo.GetDriveSize('C')
David Portas
SQL Server MVP
--|||thank you guys so much for all your useful tips!!
Dave,
thank you so much for the
function of yours, it works like a charm!!
have you been using this in your production servers? is there anything I
should look out in this function?
many thanks!!
JJ
"JJ Wang" wrote:
> hi all,
> I know that master..xp_fixeddrives can give you the free space info for ea
ch
> drive on your sql server.
> but is there any proc that can return the total disk space?
> also, anyone know how to see the code inside of master..xp_fixeddrives?
> many thanks!!
> JJ|||I have used this in production - not as something to be called
regularly but just as required to refresh a table of drive sizes. I
agree with CBretana that it makes sense to retain this information in a
table but in a large SAN environment with many drive arrays (we were
managing about 15 terabytes across 6 servers) it can be a difficult to
keep that information accurate and up-to-date.
You need to be wary about memory and resource leaks when calling COM
objects with sp_OACreate. I haven't had problems with this one (that's
under SP3, which I assume you are at) but do test it out in your
environment.
David Portas
SQL Server MVP
--|||hi Dave,
thanks again for the wonderful info!
yes, our sql servers are at the highest sp.
how long have you been using this function on your prod servers? and how
often do you refresh your drive size table? Sounds like 'daily' is a bad
idea to run the com objects, huh? :-)
how much memory and cpu in avg do your servers have(which you run this
function on)?
thanks Dave!
JJ
"David Portas" wrote:
> I have used this in production - not as something to be called
> regularly but just as required to refresh a table of drive sizes. I
> agree with CBretana that it makes sense to retain this information in a
> table but in a large SAN environment with many drive arrays (we were
> managing about 15 terabytes across 6 servers) it can be a difficult to
> keep that information accurate and up-to-date.
> You need to be wary about memory and resource leaks when calling COM
> objects with sp_OACreate. I haven't had problems with this one (that's
> under SP3, which I assume you are at) but do test it out in your
> environment.
> --
> David Portas
> SQL Server MVP
> --
>
I know that master..xp_fixeddrives can give you the free space info for each
drive on your sql server.
but is there any proc that can return the total disk space?
also, anyone know how to see the code inside of master..xp_fixeddrives?
many thanks!!
JJI don;t knoiw of any way for SQL t odo that... But...
Don't you know how big the disks are ?
These values will not change often.
Create a table and put this data in it...
"JJ Wang" wrote:
> hi all,
> I know that master..xp_fixeddrives can give you the free space info for ea
ch
> drive on your sql server.
> but is there any proc that can return the total disk space?
> also, anyone know how to see the code inside of master..xp_fixeddrives?
> many thanks!!
> JJ|||xp_fixeddrives is an extended stored proc. written in C/C++ and compiled.
It most likely calls the GetDiskFreeSpaceEx API function to get the free
space. You could always write your own extended stored proc to make the
same call, but utilize the other information returned like total disk size.
Here's more info. on that:
http://support.microsoft.com/defaul...b;en-us;231497.
It might be easier just to do it from your client app - most languages have
easier ways to get at this particular info., and I think I read that SQL
2005 will also offer easier methods to access this - but someone else will
need to give you specifics on that.
"JJ Wang" <JJ Wang@.discussions.microsoft.com> wrote in message
news:B388A868-9058-45D9-A99F-38BD00B8B0B4@.microsoft.com...
> hi all,
> I know that master..xp_fixeddrives can give you the free space info for
> each
> drive on your sql server.
> but is there any proc that can return the total disk space?
> also, anyone know how to see the code inside of master..xp_fixeddrives?
> many thanks!!
> JJ|||CREATE FUNCTION dbo.GetDriveSize (@.driveletter CHAR(1))
/* Returns the total capacity for any drive letter */
RETURNS NUMERIC(20)
BEGIN
DECLARE @.rs INTEGER, @.fso INTEGER, @.getdrive VARCHAR(13),
@.drv INTEGER, @.drivesize VARCHAR(20)
SET @.getdrive = 'GetDrive("' + @.driveletter + '")'
EXEC @.rs = sp_OACreate 'Scripting.FileSystemObject', @.fso OUTPUT
IF @.rs = 0
EXEC @.rs = sp_OAMethod @.fso, @.getdrive, @.drv OUTPUT
IF @.rs = 0
EXEC @.rs = sp_OAGetProperty @.drv,'TotalSize', @.drivesize OUTPUT
IF @.rs<> 0
SET @.drivesize = NULL
EXEC sp_OADestroy @.drv
EXEC sp_OADestroy @.fso
RETURN @.drivesize
END
GO
SELECT dbo.GetDriveSize('C')
David Portas
SQL Server MVP
--|||thank you guys so much for all your useful tips!!
Dave,
thank you so much for the
function of yours, it works like a charm!!have you been using this in your production servers? is there anything I
should look out in this function?
many thanks!!
JJ
"JJ Wang" wrote:
> hi all,
> I know that master..xp_fixeddrives can give you the free space info for ea
ch
> drive on your sql server.
> but is there any proc that can return the total disk space?
> also, anyone know how to see the code inside of master..xp_fixeddrives?
> many thanks!!
> JJ|||I have used this in production - not as something to be called
regularly but just as required to refresh a table of drive sizes. I
agree with CBretana that it makes sense to retain this information in a
table but in a large SAN environment with many drive arrays (we were
managing about 15 terabytes across 6 servers) it can be a difficult to
keep that information accurate and up-to-date.
You need to be wary about memory and resource leaks when calling COM
objects with sp_OACreate. I haven't had problems with this one (that's
under SP3, which I assume you are at) but do test it out in your
environment.
David Portas
SQL Server MVP
--|||hi Dave,
thanks again for the wonderful info!
yes, our sql servers are at the highest sp.
how long have you been using this function on your prod servers? and how
often do you refresh your drive size table? Sounds like 'daily' is a bad
idea to run the com objects, huh? :-)
how much memory and cpu in avg do your servers have(which you run this
function on)?
thanks Dave!
JJ
"David Portas" wrote:
> I have used this in production - not as something to be called
> regularly but just as required to refresh a table of drive sizes. I
> agree with CBretana that it makes sense to retain this information in a
> table but in a large SAN environment with many drive arrays (we were
> managing about 15 terabytes across 6 servers) it can be a difficult to
> keep that information accurate and up-to-date.
> You need to be wary about memory and resource leaks when calling COM
> objects with sp_OACreate. I haven't had problems with this one (that's
> under SP3, which I assume you are at) but do test it out in your
> environment.
> --
> David Portas
> SQL Server MVP
> --
>
Subscribe to:
Posts (Atom)