Below script gives you the free space for D drive. You can run this on any machine using SSMS.
The threshold of 300 can be changed as per your requirement
Use tempdb
Declare
@Free_space as varchar(max),
@Body as varchar(255)
If OBJECT_ID('#Fixeddrives') is not null
BEGIN
Drop Table #Fixeddrives
Create Table #Fixeddrives
(
drives varchar(2),
FreeSpace bigint
)
INSERT INTO #Fixeddrives
Exec sys.xp_fixeddrives
Select @Free_space = FreeSpace/1024
From #Fixeddrives
Where drives='D' and (FreeSpace)/1024< = 300
Drop Table #Fixeddrives
END
if @Free_space < 300
BEGIN
Select @Body = 'SERVER NAME - Total Free space on D drive is: ' + @Free_space + ' GB'
EXEC msdb.dbo.sp_send_dbmail
@profile_name = 'PROFILE NAME',
@recipients ='TO EMAIL ADDRESS',
@body = @Body,
@subject = 'SERVER NAME - Low disk space',
@Importance = 'HIGH'
END
"Scripting" is basically giving sequential instructions to computer for doing specific things rather than doing manually. Sometimes we need to write a small and quick vbscript (.vbs), javascript(.js), batch file(.bat) or SQL script(.sql) to perform a short task, but we lack information or get confuse on where to start or which scrpit to write. In my BLOG, I will try to cover as many different scripts as possible that will be useful to everyone.
Showing posts with label Sql Job. Show all posts
Showing posts with label Sql Job. Show all posts
Wednesday, June 29, 2011
Get Current SQL Job running on a server
Run the below script in your SQL Server:
msdb.dbo.sp_get_composite_job_info NULL, NULL, NULL, NULL, NULL, NULL, 1, NULL, NULL
msdb.dbo.sp_get_composite_job_info NULL, NULL, NULL, NULL, NULL, NULL, 1, NULL, NULL
Subscribe to:
Posts (Atom)