Checking Disk Space
May 14, 2008
Another question...
I need to check the space available on a specific disk (D on a remote server, again, this task will be executed from an SSIS package, if I have less than 60GB available, I have to delete some files.
How would you guys do this using VB.NET? If I had SQL Server installed on that box, I could achieve this executing a DOS command... But I don't...
Thanks!
View 6 Replies
ADVERTISEMENT
Sep 13, 2006
Hello
I have a script which checks the disk space and when it falls a certain size , it mails the dba mail box.
I would like to know how I can change it , as a percentage calculation.
For example when the free space is less than 20% of the total space on the drive I should be receiving a mail.
The script I have is :
declare @MB_Free int
create table #FreeSpace(
Drive char(1),
MB_Free int)
insert into #FreeSpace exec xp_fixeddrives
-- Free Space on F drive Less than Threshold
if @MB_Free < 4096
exec master.dbo.xp_sendmail
@recipients ='dvaddi@domain.edu',
@subject ='SERVER X - Fresh Space Issue on D Drive',
@message = 'Free space on D Drive
has dropped below 2 gig'
drop table #freespace
Thanks
View 1 Replies
View Related
Sep 22, 2006
Hello
I have got a script which checks the percentage of free space on the drivers of the servers and mails the DBA when it falls below a certain percentage , which can be set according to our requirements.
But I am getting blank emails even when , there is no issue of low free space.
Please help me out.
The code , 1st part of it is:
use master
go
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
create PROCEDURE usp_diskspace
@Percentagefree int,
@error2 varchar(8000) OUTPUT
AS
SET NOCOUNT ON
DECLARE @hr int, @fso int, @drive char(1), @odrive int, @TotalSize varchar(20), @MB bigint , @COUNT int, @Maxcount int,@error varchar(700), @errordrive char(1),@errortotalspace varchar(20), @errorfreespace varchar(20), @free int, @date varchar(100), @query varchar(1300)
SET @MB = 1048576
set @date = convert(varchar(100), getdate(),109)
set @error2=''
select @query= 'master.dbo.xp_fixeddrives'
set @date = convert(varchar(100), getdate(),109)
set @error2=''
select @query= 'master.dbo.xp_fixeddrives'
CREATE TABLE #drives (id int identity(1,1),ServerName varchar(15),
drive char(1) PRIMARY KEY,
FreeSpace int NULL,
TotalSize int NULL,
FreespaceTimestamp DATETIME NULL)
INSERT #drives(drive,FreeSpace)
EXEC @query
EXEC @hr=sp_OACreate 'Scripting.FileSystemObject',@fso OUT
IF @hr <> 0 EXEC sp_OAGetErrorInfo @fso
DECLARE dcur CURSOR LOCAL FAST_FORWARD
FOR SELECT drive from #drives
ORDER by drive
OPEN dcur
FETCH NEXT FROM dcur INTO @drive
WHILE @@FETCH_STATUS=0
BEGIN
EXEC @hr = sp_OAMethod @fso,'GetDrive', @odrive OUT, @drive
IF @hr <> 0 EXEC sp_OAGetErrorInfo @fso
EXEC @hr = sp_OAGetProperty @odrive,'TotalSize', @TotalSize OUT
IF @hr <> 0 EXEC sp_OAGetErrorInfo @odrive
UPDATE #drives
SET TotalSize=@TotalSize/@MB, ServerName = replace( @query , 'master.dbo.xp_fixeddrives',''), FreespaceTimestamp = (GETDATE())
WHERE drive=@drive
FETCH NEXT FROM dcur INTO @drive
END
CLOSE dcur
DEALLOCATE dcur
EXEC @hr=sp_OADestroy @fso
IF @hr <> 0 EXEC sp_OAGetErrorInfo @fso
set @maxcount =(select max(id) from #drives)
set @count=1
while @count <=@maxcount
begin
select @errortotalspace =convert(varchar(20),Totalsize), @errorfreespace =freespace, @free=CAST((FreeSpace/(TotalSize*1.0))*100.0 as int),@errordrive=Drive from #drives where id = @count
if @free<@percentagefree
begin
set @error = 'Server = '+@@servername+': Drive=' + @errordrive+': Percentage free=' +convert(varchar(2),@free)+'% TotalSpace ='+ @errortotalspace +'MB : FreeSpace ='+ @errorfreespace +'MB ate =' +@date
set @error2=@error2+@error+char(13)
end
else
begin
set @error = 'Server = '+@@servername+': Drive=' + @errordrive+': Percentage free=' +convert(varchar(2),@free)+'% TotalSpace ='+ @errortotalspace +'MB : FreeSpace ='+ @errorfreespace +'MB ate =' +@date
end
set @count=@count+1
end
DROP TABLE #drives
set @date = convert(varchar(100), getdate(),109)
GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO
The 2nd step which sends the mail is :
set nocount on
declare @msg varchar(8000)
declare @minimumspace int
set @minimumspace = 10
set @msg = 'Running out of Hard Disk space on the Server: '+@@servername
exec usp_diskspace @minimumspace,@msg OUTPUT
print @msg
if @msg is not null
EXEC master.dbo.xp_smtp_sendmail
@FROM = N'fromaddress',
@TO = N'toaddress',
@server = N'smtp address',
@subject = N'Free Space of Drivers Test sqlserver2000!',
@type = N'text/html',
@message = @msg
How can I change to get the mail only when there is a free space issue.
Thanks
View 3 Replies
View Related
Sep 22, 2006
Hello
I have got a script which checks the percentage of free space on the drivers of the servers and mails the DBA when it falls below a certain percentage , which can be set according to our requirements.
But I am getting blank emails even when , there is no issue of low free space.
Please help me out.
The code , 1st part of it is:
use master
go
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
create PROCEDURE usp_diskspace
@Percentagefree int,
@error2 varchar(8000) OUTPUT
AS
SET NOCOUNT ON
DECLARE @hr int, @fso int, @drive char(1), @odrive int, @TotalSize varchar(20), @MB bigint , @COUNT int, @Maxcount int,@error varchar(700), @errordrive char(1),@errortotalspace varchar(20), @errorfreespace varchar(20), @free int, @date varchar(100), @query varchar(1300)
SET @MB = 1048576
set @date = convert(varchar(100), getdate(),109)
set @error2=''
select @query= 'master.dbo.xp_fixeddrives'
set @date = convert(varchar(100), getdate(),109)
set @error2=''
select @query= 'master.dbo.xp_fixeddrives'
CREATE TABLE #drives (id int identity(1,1),ServerName varchar(15),
drive char(1) PRIMARY KEY,
FreeSpace int NULL,
TotalSize int NULL,
FreespaceTimestamp DATETIME NULL)
INSERT #drives(drive,FreeSpace)
EXEC @query
EXEC @hr=sp_OACreate 'Scripting.FileSystemObject',@fso OUT
IF @hr <> 0 EXEC sp_OAGetErrorInfo @fso
DECLARE dcur CURSOR LOCAL FAST_FORWARD
FOR SELECT drive from #drives
ORDER by drive
OPEN dcur
FETCH NEXT FROM dcur INTO @drive
WHILE @@FETCH_STATUS=0
BEGIN
EXEC @hr = sp_OAMethod @fso,'GetDrive', @odrive OUT, @drive
IF @hr <> 0 EXEC sp_OAGetErrorInfo @fso
EXEC @hr = sp_OAGetProperty @odrive,'TotalSize', @TotalSize OUT
IF @hr <> 0 EXEC sp_OAGetErrorInfo @odrive
UPDATE #drives
SET TotalSize=@TotalSize/@MB, ServerName = replace( @query , 'master.dbo.xp_fixeddrives',''), FreespaceTimestamp = (GETDATE())
WHERE drive=@drive
FETCH NEXT FROM dcur INTO @drive
END
CLOSE dcur
DEALLOCATE dcur
EXEC @hr=sp_OADestroy @fso
IF @hr <> 0 EXEC sp_OAGetErrorInfo @fso
set @maxcount =(select max(id) from #drives)
set @count=1
while @count <=@maxcount
begin
select @errortotalspace =convert(varchar(20),Totalsize), @errorfreespace =freespace, @free=CAST((FreeSpace/(TotalSize*1.0))*100.0 as int),@errordrive=Drive from #drives where id = @count
if @free<@percentagefree
begin
set @error = 'Server = '+@@servername+': Drive=' + @errordrive+': Percentage free=' +convert(varchar(2),@free)+'% TotalSpace ='+ @errortotalspace +'MB : FreeSpace ='+ @errorfreespace +'MB :Date =' +@date
set @error2=@error2+@error+char(13)
end
else
begin
set @error = 'Server = '+@@servername+': Drive=' + @errordrive+': Percentage free=' +convert(varchar(2),@free)+'% TotalSpace ='+ @errortotalspace +'MB : FreeSpace ='+ @errorfreespace +'MB :Date =' +@date
end
set @count=@count+1
end
DROP TABLE #drives
set @date = convert(varchar(100), getdate(),109)
GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO
The 2nd step which sends the mail is :
set nocount on
declare @msg varchar(8000)
declare @minimumspace int
set @minimumspace = 10
set @msg = 'Running out of Hard Disk space on the Server: '+@@servername
exec usp_diskspace @minimumspace,@msg OUTPUT
print @msg
if @msg is not null
EXEC master.dbo.xp_smtp_sendmail
@FROM = N'fromaddress',
@TO = N'toaddress',
@server = N'smtp address',
@subject = N'Free Space of Drivers Test sqlserver2000!',
@type = N'text/html',
@message = @msg
How can I change to get the mail only when there is a free space issue.
Thanks
View 1 Replies
View Related
Nov 13, 2007
-- Initialize Control Mechanism
DECLARE@Drive TINYINT,
@SQL VARCHAR(100)
SET@Drive = 97
-- Setup Staging Area
DECLARE@Drives TABLE
(
Drive CHAR(1),
Info VARCHAR(80)
)
WHILE @Drive <= 122
BEGIN
SET@SQL = 'EXEC XP_CMDSHELL ''fsutil volume diskfree ' + CHAR(@Drive) + ':'''
INSERT@Drives
(
Info
)
EXEC(@SQL)
UPDATE@Drives
SETDrive = CHAR(@Drive)
WHEREDrive IS NULL
SET@Drive = @Drive + 1
END
-- Show the expected output
SELECTDrive,
SUM(CASE WHEN Info LIKE 'Total # of bytes : %' THEN CAST(REPLACE(SUBSTRING(Info, 32, 48), CHAR(13), '') AS BIGINT) ELSE CAST(0 AS BIGINT) END) AS TotalBytes,
SUM(CASE WHEN Info LIKE 'Total # of free bytes : %' THEN CAST(REPLACE(SUBSTRING(Info, 32, 48), CHAR(13), '') AS BIGINT) ELSE CAST(0 AS BIGINT) END) AS FreeBytes,
SUM(CASE WHEN Info LIKE 'Total # of avail free bytes : %' THEN CAST(REPLACE(SUBSTRING(Info, 32, 48), CHAR(13), '') AS BIGINT) ELSE CAST(0 AS BIGINT) END) AS AvailFreeBytes
FROM(
SELECTDrive,
Info
FROM@Drives
WHEREInfo LIKE 'Total # of %'
) AS d
GROUP BYDrive
ORDER BYDrive
E 12°55'05.25"
N 56°04'39.16"
View 16 Replies
View Related
Nov 28, 2007
How to write the stored procedure or SSIS package to check the hardisk space?
SQL Server 2005 SP2
Thank you,
Smith
View 3 Replies
View Related
Nov 19, 2000
Hello
I need to setup a compaq sever with 300 MB database, and will be adding around 600 records on a daily basis. Can someone help with how much disk space i should have on sqlserver, providing i have c: and d: setup.
Thank you in advance for all the help.
Paula
View 1 Replies
View Related
Feb 19, 2001
Hi All,
I have a server and it has C: D: F: I: Drives and all the system files are on C:Drive and and all the .MDF's and .LDF's(model,temp,master) are on the F: Drive and now I am running out of space on both(C: and F: Drives)
1. Can we add space to the C: and F: drives on the fly?.
2. Can I move the System databases ( MDF's and LDF's to some other drive)and if so, how do I do it?( Moving the databases ) and this is on the production database so when I have to do this.Will there be any impact.
Thanks in Advance,
Reddy
View 2 Replies
View Related
Feb 21, 2003
Does anyone know how to get the free disk space for all drives in many different SQL servers.
I need to populate a report (right now output in Excel) with the free disk space of all drives on all of my SQL servers.
I found xp_fixeddrives but that is specific for the server where it is executed.
Any help or pointers to a script in the archives is much appreciated.
Thanks.
View 2 Replies
View Related
Aug 2, 2004
I noticed something strange today. I was running a query using query analyzer on a large database (8.8 million records) and the disk space on the c: drive was dropping and eventually went to 0. Availalbe space on the c: drive is 10GB. The query did complete. SQL server and all the databases are on the d: drive. After closing the query results in query analyzer the disk space returned. Is this a concern and is there a way to change it to use the d: for whatever it is doing?
View 3 Replies
View Related
Jun 30, 2006
This is my first attempt using SQL 2000 and DTS. I am importing an Access database using the DTS wizard. The process fails with a "Not enough space on temporary disk" error. There is definitely enough space on the physical disk. I don't have any limits on any folder sizes either. What "disk" is the error talking about, and how do I give it enough space. The database is relatively small, about 10MB. I believe the database was created using Access 97. Please help.
View 1 Replies
View Related
Feb 21, 2002
I need a way to get the used space for a physical drive, or even the total capacity for a drive to do some calculations.
I don't want to have to write my own native code either.
Is there a stored procedure that will give this to me?
I saw the xp_fixeddrives that will give the free space, but I need one of the other as well.
Any way to get this?
Thanks,
Jason
View 2 Replies
View Related
May 9, 2000
We recently moved from v6.5 to v7.0. Now I have the databases and logs set to "autogrow". How can I monitor the disk space to ensure I do not run out of room (or is that preset as to how large it can grow ?). Can't find anything in the books online. Do I do this through the NT admin tool or through the SQL*Server Enterprise Manager and more importantly - how ???
Thanks so much for any help...
Nancy
View 3 Replies
View Related
Feb 19, 2001
I'm trying to save a dts package and it keeps coming back with insufficient disk space. I noiticed that db MSDB was full so I manually increased the size. It was set to manually grow at 1 mb increments. But for some reason it didn't look like it was doing that so I manually increased it. Right now this is about 355 MB free so that should be plenty to save a package. But its still coming back with the same error insufficient disk space to complete operation. Any ideas on why or why it didn't grow on its own? Please help I can't seem to save any packages.
View 1 Replies
View Related
Feb 2, 2000
Our database -SQL Server 7.0 sp1 (NT 4.0 sp5)- is growing at a very fast rate despite the fact that we are deleting old record. It doesn't seem to be recovering disk space for the deleted records. Please let me know if there is a specific setting that can help us recover disk space. )
View 1 Replies
View Related
Mar 23, 2006
Hi,
I'm new to these forums (and to SQL Server), so please be gentle with me.
I am developing a process to obtain information on all our remote servers/databases, and store it in a single local database.
I'm after things like db size, last backup date, free drive space etc...the usual weekly statistics.
I've linked the remote servers to my local one, and have written a few simple procedures (which exist on the local server) to grab backup and file size information from the remote tables. The output is stored locally in tables which we can then query as necessary.
I am having difficulty obtaining the free drive space details.
I'm using :-
'exec <remote_server>.master.dbo.xp_fixeddrives' to get the info, but I cannot store the output in a table on the local server. (remote_server_name, date, drive_letter, space_mb)
I wish to avoid creating any objects on the remote servers if at all possible.
I really want to pass the remote server name into the procedure, and the output to be inserted into the table.
Many thanks
View 4 Replies
View Related
May 7, 2008
is there a tsql command that returns the amount of disk space available. I want to set up a job to run and email if it gets to a certain level.
View 1 Replies
View Related
Jan 18, 2007
Hi
I have 600 instances on my network .... I need to monitor the Disk Space ... how should I do that I mean the best way for this would be ???
By Disk Space I mean the SQL Instance should atleat have 10% of free disk space ... If it is less , maybe an alert can be sent or something of that sort .
Now it would be a pain configuring alerts on each machine.
Is there some good way to this
Thanks in advance.
View 6 Replies
View Related
Aug 8, 2007
All,
I think i know the answer to this one already, but would like to check before going back to my management.
Background. In the past 2 weeks, a number of our databases have shot up in size, and are now at 100% utilisation of allocated disk space. My management have asked me to look into what is causing these to fill up so quickly.
Unfortunatly there were no snap shots or information relating to the databases / tables so i can not determine which tables have grown and are causing the problems.
I have also looked through the sql logs and the event viewer logs to see if there is anything out of the ordinary, but again apart from log / database backups there is nothing of note in there.
I am going to be implementing a solution that I got off another thread which will give me some database / table history to help me in the future, but for now is there anything else i can do? or is it a case of me getting back to the application guys and getting them to reduce data (as there is no more disk space to give them).
Any thoughts or advice you can give me would be greatfully received.
Mark
-noob dba-
View 14 Replies
View Related
Nov 12, 2007
Okay, so i have a Dual Xeon SQL2k5 Server set up. it's got 4 10k RPM Raptor Drivers (160gb) on it all stripped together. my question is this, i was just doing all kinds of index tuning, and my server didnt have enough disk space to create 2two of the recommended adjustments. i'm curious, if i should just have those two indexes stored on the 1TB Backup array i have? (two 500gb 7200RPM drives)
or should i backup the database, and expand the Raptor Array and then restore the database and create the indexes?
i'm not really worried about down time as long as it doesnt exceed 2 days.
View 3 Replies
View Related
Nov 29, 2007
All,
I first ran indexdefrag on a table with 1.5 billion rows.
logical fragmentation was at 95%.
logical frag went down to 3% with no real effect on disk.
DBCC reindex had previously been bombing undetected.
Now I've run a reindex on this table:
Reindex Job with Fillfactor =100
Ran in 3:05
Free Disk went from ~150GB before operation to 49GB
File4 went from 347GB to 504GB
Why has so much free disk been consumed by this operation and not released ??????????
Is my only choice to shrink data file???
thanks
Env.
Win2k ENT os
SQL 2k5 std 64bit
View 4 Replies
View Related
Mar 2, 2008
one user database ldf file is growing like it reached 50GB and total D: drive space is 70GB. No SAN drives for D:. I tried to shrink the file but it not shrinking. Even I tried take to Tlog backup but it is throwing the below error
'not enough disk space'
This is production server. Please let me know how to resolve this issue?
View 5 Replies
View Related
Mar 2, 2008
one user database ldf file is growing like it reached 50GB and total D: drive space is 70GB. No SAN drives for D:. I tried to shrink the file but it not shrinking. Even I tried take to Tlog backup but it is throwing the below error
'not enough disk space'
This is production server. Please let me know how to resolve this issue?
View 6 Replies
View Related
Nov 16, 2007
I need to find out how much space is available on a disk (ex. C on the server from within a stored proc on ss2000. Is there an easy way?
Thanks!
View 1 Replies
View Related
Oct 5, 2007
I heard somewhere that using reporting services you are able to report on more useful aspects also such as server disk space, how is this possible, or where can i find any tutorials to help me out
thanks in advance
Jonny
View 5 Replies
View Related
Aug 13, 2002
Hello ,
I wanted to know on what basis the disk space allocation for the databases is planned . Suppose if we plan 60 GB for data files ( mdf )for a given database then what should be the space allocation for the log files ( ldf ) and the tempdb ( both mdf and ldf files ).
Is there any thumb rule or any defined ratio for the same ?
Thanks
View 1 Replies
View Related
Mar 30, 1999
Hello
I am trying to upgrade our 6.5 server (which approx takes up 18GIG of data/log) to 7.0...it failed since I only have 7GIG space left.
Do I realy need to come up with an additional 18GIG to accomodate the upgrade?
Thanks. Bob
View 1 Replies
View Related
Feb 12, 2003
We are experiencing an intermittent locking or hanging problem on our SQL Server (at the application level on the clients) and it has gotten worse very recently.
I haven't seen any processes that appear to be locked yet but I noticed that we don't have a lot of space available (the database is 1.4 gigs and we have about 245 megs available).
If this is inadequate disk space, could that be causing an apparent locking problem?
Thanks in advance for any help.
View 3 Replies
View Related
Dec 3, 2007
Hi All,
One of the drives that stores the database file is close to running out of space. The chance of me getting more space added to this drive any time soon are really low. What are other options I have?
Thanks.
View 2 Replies
View Related
Jun 22, 2004
We've got an internal database that replicates with another database server for our website.
Not all tables are replicated, some use merge and the others are snapshot based and published regularly to the public website facing server.
However, there's a lot of data (well, large textual data) that's being transferred and it seems to be generating massive log files that continue to grow and grow.
I'm fairly new to adminning an SQL Server box, so was wondering if anyone can tell me what the best way to keep it under control is? I've heard its possible to truncate the logs, effectively deleting any data that has already been processed by subscribing servers etc.?
As I said, I'm very much new to this and would really appreciate some guidance, if only to the right part of the SQL Server Books Online :)
Thanks,
Paul
View 2 Replies
View Related
Oct 17, 2006
Hi,
I have a 250 GB database and not much space left on the disk drive. I want to run SQLMAINT to do optimization and integrity checks on this db. My question is : How much work space does SQLMAINT need to perform these tasks?.
Thanks in advance for your help.
F.
View 1 Replies
View Related
Dec 3, 2007
Hi All,
One of the drives that stores the database file is close to running out of space. The chance of me getting more space added to this drive any time soon are really low. What are other options I have?
Thanks.
View 1 Replies
View Related
Sep 19, 2007
HI All
how to calculate the disk storage space of the database from the front using asp.net
Can anyone give suggestion
Thanks
View 6 Replies
View Related