SQL agent scheduling for SSIS package
I have a package with a souce and destination connection using login as 'sa'.
I created a scheduling task to call this package for running. However the sql agent service is running as domain user . It required to be running as domain user as per requirement.
Thus when I scheduling the package for execution, it hit error.
Please advise what I can do in order to be able schedule the ssis package?
Thanks in advance.
Here is the step that I create the proxy :
https://www.simple-talk.com/sql/database-administration/setting-up-your-sql-server-agent-correctly/
I try to create the proxy but still have error as below:
Executed as user: YS2H\svr_agent. Microsoft (R) SQL Server Execute Package Utility Version 10.50.2500.0 for 32-bit Copyright (C) Microsoft Corporation 2010. All rights reserved. Started: 8:21:26 AM Error: 2015-03-27
08:21:26.24 Code: 0xC0016016 Source: Description: Failed to decrypt protected XML node "DTS:Password" with error 0x8009000B "Key not valid for use in specified
state.". You may not be authorized to access this information. This error occurs when there is a cryptographic error. Verify that the correct key is available. End Error Error: 2015-03-27 08:21:26.44 Code: 0xC0016016
Source: Description: Failed to decrypt protected XML node "DTS:Password" with error 0x8009000B "Key not valid for use in specified state.". You may not be authorized to access this information. This error
occurs when there is a cryptographic error. Verify that the correct key is available. End Error Error: 2015-03-27 08:21:27.03 Code: 0xC0202009 Source: 1001_Import_DownloadRoadCard Connection manager
"Destination" Description: SSIS Error Code DTS_E_OLEDBERROR. An OLE DB error has occurred. Error code: 0x80040E4D. An OLE DB record is available. Source: "Microsoft SQL Server Native Client 10.0"
Hresult: 0x80040E4D Description: "Login failed for user 'sa'.". End Error Error: 2015-03-27 08:21:27.03 Code: 0xC00291EC Source: Evaluate Completion Status Execute SQL Task
Description: Failed to acquire connection "Destination". Connection may not be configured correctly or you may not have the right permissions on this connection. End Error Error: 2015-03-27 08:21:27.05 Code: 0xC0202009
Source: 1001_Import_DownloadData Connection manager "Destination" Description: SSIS Error Code DTS_E_OLEDBERROR. An OLE DB error has occurred. Error code: 0x80040E4D. An OLE DB record is available. Source:
"Microsoft SQL Server Native Client 10.0" Hresult: 0x80040E4D Description: "Login failed for user 'sa'.". End Error Error: 2015-03-27 08:21:27.05 Code: 0xC00291EC Source:
Record Start of Job Execute SQL Task Description: Failed to acquire connection "Destination". Connection may not be configured correctly or you may not have the right permissions on this connection. End Error DTExec:
The package execution returned DTSER_FAILURE (1). Started: 8:21:26 AM Finished: 8:21:27 AM Elapsed: 0.983 seconds. The package execution failed. The step failed.
Thanks for your help.
Similar Messages
-
How do I automatically backup SQL Agent jobs and SSIS packages on the mirror daily?
I have seen this question asked before but I could not find a satisfactory answer. What is the best solution to get your SQL Agent jobs/schedules/etc. and your SSIS packages on the mirror server? Here's the details:
Server A is the principal with 2 DBs mirrored over to server B. Everything is fine and dandy, DBs are synched and all good. In Disaster Recovery testing, we need to bring up server B, which now will serve as the principal. Server A is inaccessible. Now,
we need all our jobs that are setup in server A to be in server B, ready to go, but disabled. We also need all our SSIS packages properly stored. Yes, we store our packages in the MSDB in server A.
Now, I can see a few answers coming my way.
1- Backup the MSDB to server B. When you bring server B up as principal in DR, restore the MSDB. All your jobs,schedules,steps, SSIS packages will be there. Is this possible? Can this be done on server B without rendering it incapable of serving as the principal
for the mirrored DBs? My fear with this option is that there may be information in the MSDB itself about the mirroring state of the DBs? Or is all that in the Master DB? Have you tried this?
2- Right click each job, script them out, re-create them on server B... No, thank you very much. :) I am looking for an AUTOMATED, DAILY backup of the jobs and SSIS packages. Not a manual process. Yes, we do change jobs and packages quite often and doing
the job twice on two servers is not an option.
3- Use PowerShell.. Really? Are we going back to scripting at the command prompt like that, that fast?
Since I fear option number 3 will be the only way to go, any hints on scripts you guys have used that you like that does what I need to do?
Any other options?
Any help GREATLY appreciated. :-) I can be sarcastic but I am a good guy..
Raphael
rferreiraI would go with option number 3. Once you have a script simple run it....
param([string]$serverName,[string]$outputPath)
function script-SQLJobs([string]$server,[string]$outputfile)
[reflection.assembly]::LoadWithPartialName("Microsoft.SqlServer.Smo") | Out-Null
$srv = New-Object Microsoft.SqlServer.Management.Smo.Server("$server")
$db = New-Object Microsoft.SqlServer.Management.Smo.Database
$scrp = New-Object Microsoft.SqlServer.Management.Smo.Scripter($srv)
$scrp.Options.ScriptDrops = $FALSE
$scrp.Options.WithDependencies = $TRUE
$jobs = $srv.JobServer.get_Jobs()
$jobs=$jobs | Where-Object {$_.Name -notlike "sys*"}
foreach($job in $jobs)
$script=$job.Script()
$script >> $outputfile
"GO" >> $outputfile
---script-SQLJobs "SQLSRV12" "C:\Jobs\test.txt"
Best Regards,Uri Dimant SQL Server MVP,
http://sqlblog.com/blogs/uri_dimant/
MS SQL optimization: MS SQL Development and Optimization
MS SQL Blog:
Large scale of database and data cleansing
Remote DBA Services:
Improves MS SQL Database Performance -
If I setup a job step to run a package and set the config file location on the "Configurations" tab, will that override the config file that the SSIS package is configured to use? Or is this a "cumulative" type configuration option?
I typically have my config file mixed in with my project files, but that path wont exist on the server.Hi Shiftbit,
ETL vs ELT is right.
In SSIS 2005, the DTExec utility loads and runs the package, events occur in the following order:
The package file is loaded.
The configurations specified in the package at design time are applied in the order specified in the package (except for Parent Package Variables).
Any options specified from the command line are applied. Any configurations specified on the command line overwrite the current values; however, they do not trigger a reload of the configurations if a changed value impacts a configuration dependency. For
example, if the connection string used for SQL Server configurations is updated from the command line at run time, the package will still retain any other values from the design-time SQL Server configuration database.
Parent Package Variable Configurations are applied.
The package is run.
In SSIS 2008 and higher, utility loads and runs the package, events occur in the following order:
The dtexec utility loads the package.
The utility applies the configurations that were specified in the package at design time and in the order that is specified in the package. (The one exception to this is the Parent Package Variables configurations. The utility applies these configurations
only once and later in the process.)
The utility then applies any options that you specified on the command line.
The utility then reloads the configurations that were specified in the package at design time and in the order specified in the package. (Again, the exception to this rule is the Parent Package Variables configurations). The utility uses any command-line
options that were specified to reload the configurations. Therefore, different values might be reloaded from a different location.
The utility applies the Parent Package Variable configurations.
The utility runs the package.
So, we can see that no matter we use SSIS 2005 which applies the Configurations once or use SSIS 2008 (or higher) which applies the configurations twice, the configurations specified in the command line will affect and not be overwritten by the configurations
specified at design-time.
Reference:
http://technet.microsoft.com/en-us/library/ms141682(v=sql.110).aspx.
Regards,
Mike Yin
TechNet Community Support -
How to Create a SQL Agent Job For A SSIS Package with Sql Server Authentication
Hi ALl,
I have a SSIS package which basically has a data flow task in which i pull the data from one server and copy it into another server and my source server is the one where i dont have windows authentication and i have to only use a sql server authentication
. This package runs fine if i click the server connection properties type the password and save it.
Now, my task is to set up a sql agent job which basically uses a proxy account and takes this package from the file system and runs it.But when i try to run this package, its failing with an error saying
"Login Failed For rpt5user" where rpt5user is the username for my sql server authentication of the source connection.
Can someone please help me with any suggestions on how to do this?
I have heard that we can achieve it by using xml config file which i have never used and i am trying to google around but for no luck.
So, If someone can please throw any suggestions or ideas on this it would be great.
ThanksYou need to add password as a config item and set it from the file source or sql table
see this as an example
http://blogs.msdn.com/b/runeetv/archive/2009/12/22/ssis-package-using-sql-authentication-and-dontsavesensitive-as-protectionlevel.aspx
Please Mark This As Answer if it solved your issue
Please Mark This As Helpful if it helps to solve your issue
Visakh
My MSDN Page
My Personal Blog
My Facebook Page -
Hi,
I can able ran the SSIS package in BIDS, since set to false in Run64BitRuntime property.
Then I created SQL server Agent job I tried the following ways
Step 1:
Type is set as SQL Server Integration Services Packages,
Run as - SQL Server Agent Service Account
Package source - FileSystem
then Execution option tab I selected 32 bit runtime
and then run the job I am getting the below error
Message
Executed as user: CIT\svc_CS_SS2008Agent. Microsoft (R) SQL Server Execute Package Utility Version 11.0.2100.60 for 32-bit Copyright (C) Microsoft Corporation. All rights reserved. Started: 7:29:17 AM Error: 2013-11-28
07:29:18.57 Code: 0xC0014020 Source: Example Connection manager "DataSource.DataExtract" Description: An ODBC error -1 has occurred. End Error Error: 2013-11-28 07:29:18.57
Code: 0xC0014009 Source: Imports20_OAC_Gifts Connection manager "DataSource.DataExtract" Description: There was an error trying to establish an Open Database Connectivity (ODBC) connection with the
database server. End Error Error: 2013-11-28 07:29:18.59 Code: 0x0000020F Source: DFT_Example ODBC_SRC Example [11] Description: The AcquireConnection method call to the connection
manager DataSource.DataExtract failed with error code 0xC0014009. There may be error messages posted before this with more information on why the AcquireConnection method call failed. End Error Error: 2013-11-28 07:29:18.59
Code: 0xC0047017 Source: DFT_Example SSIS.Pipeline Description: ODBC_SRC Example failed validation and returned error code 0x80004005. End Error Error: 2013-11-2
Step 2:
Type - Operating sytem (CmdExec)
Run as - Sql Server agent service account
Command - C:\Program Files\Microsoft SQL Server\110\DTS\Binn\dtexec.exe /FILE "D:\Example\Example.dtsx" /x86 /CHECKPOINTING OFF /REPORTING E
then run the job I am getting the below error
Message
Executed as user: MIS\svc_CS_SS2008Agent. Microsoft (R) SQL Server Execute Package Utility Version 11.0.2100.60 for 64-bit Copyright (C) Microsoft Corporation. All rights reserved. Started: 6:37:58 AM Error: 2013-11-28
06:37:58.94 Code: 0xC0014020 Source: Example Connection manager "DataSource.DataExtract" Description: An ODBC error -1 has occurred. End Error Error: 2013-11-28 06:37:58.96
Code: 0xC0014009 Source: Example Connection manager "DataSource.DataExtract" Description: There was an error trying to establish an Open Database Connectivity (ODBC) connection with the database server.
End Error Error: 2013-11-28 06:37:59.01 Code: 0x0000020F Source: DFT_Example ODBC_SRC Example [11] Description: The AcquireConnection method call to the connection manager DataSource.DataExtract
failed with error code 0xC0014009. There may be error messages posted before this with more information on why the AcquireConnection method call failed. End Error Error: 2013-11-28 06:37:59.07 Code: 0xC0047017
Source: DFT_Example SSIS.Pipeline Description: ODBC_SRC Example failed validation and returned error code 0x80004005. End Error Error: 2013-11-28 06:37:59.12 Code: 0xC004700C
Source: DFT_Example SSIS.Pipeline Description: One or more component failed validation. End Error Error: 2013-11-28 06:37:59.16 Code: 0xC0024107 Source: DFT_Example
Description: There were errors during task validation. End Error DTExec: The package execution returned DTSER_FAILURE (1).Started: 6:37:58 AM Finished: 6:37:59 AM Elapsed: 1.373 seconds. Process Exit Code 1.
The step failed.
Note:
My source server is 32 bit and development environment in 64 bit
if anybody have idea please share your knowledgeHi BIRam,
Based on the current information, the issue may be caused by the factor that the SQL Server Agent Service Account doesn’t have access to the MySQL server. Try to create a SQL Server Agent Proxy account that has sufficient permission on the MySQL server.
In addition, also pay attention to the package protection level setting.
For more information, please see:
http://social.technet.microsoft.com/Forums/sqlserver/en-US/e13c137c-1535-4475-8c2f-c7e6e7d125fc/how-do-i-troubleshoot-ssis-packages-failed-execution-in-a-sql-agent-job?forum=sqlintegrationservices.
Regards,
Mike Yin
TechNet Community Support -
SQL SERVER AGENT JOB ERROR - SSIS PACKAGE
Hi ,
I have a SQL server agent job which runs SSIS package as the daily job. The SSIS package contains multiple child package. Its a master package which calls other SSIS package. The master package calls 23 SSIS packages, few of the packages runs in parallel.
I am getting the below 2 different errors more frequently. It fails only in the production server, I scheduled the job in UAT server, it did not fail. Also when we run the master package with out sql agent job, it did not fail.
Error 1 :
R6025 - pure virtual function call. The return value was unknown. The process exit code was 255. The step failed.
Error 2 : The step did not generate any output. The return value was unknown. The process exit code was -1073741819. The step failed.
We tried browsing for the answers ,no luck. It failing in live , so we need to run the package manually in live server every time.
Please help me to resolve this issue. Thanks in advance.
Regards,
Dhivya SivakumarHi Vijeth,
Thanks for your reply.
1) Run the Package manually and check whether it runs successfully. -
No Failures. Package completed succesfully
2) If Step 1 is successful,
a) Point the same package to the UAT database and run it and check whether it runs successfully or not. -
We tried to schedule the package almost for 1 month. No failures in UAT.
b) In UAT database, point to the Production database and run the package. - I am not sure, if i can do this.I will try and let you know the result.
These steps will help us identify whether the problems lies within the package or the Environment.
3) Run the Package manually in production Environment using dtexec utilily. -
No Failures. Success.
4) Check the ID used to run the SQL Agent job and modify to an account with elevated permissions or GRANT more permissions to the existing ID. -
The account used currently is having all the privileges. Its the most powerful user in live DB.
Regards,
Dhivya S -
SQL Agent Permssions With SSIS for each loop not looping through files
Hi I am Having trouble getting a ssis package to iterate through a file directory using a proxy account set up in Sql Server.
So I have a package that loops over csv files. If I run the package manually or set the sql agent job to run as Sysadmin the pakage runs fine all files are processed.
However if I use the proxy account. the package completes but no files are processed. there are no failures, there is no error handling set up in the control flow. the for each loop container simply does not recognise any files when run under a proxy.
Note: the proxy is set up with credentials to access the folder. the credential is also set up with the server admin server role... still nothing
i'm not sure is this is a ssis or permissions problem?
Any comments will be appreciatedCan you check this and see if you've configured all the steps correctly
http://www.mssqltips.com/sqlservertip/2163/running-a-ssis-package-from-sql-server-agent-using-a-proxy-account/
Also enable logging in package and see if you're getting any error messages obtained in output table/file based on the logging option you chose.
Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs -
I want to script XMLA file instead of backup of database and also want to schedule a job for the process in SQL Agent.
Is there any pros and cons when I script the XMLA file of the SSAS db instead of taking a backup ?
AmirHi Amir,
You can take the Create SSAS database XMLA script and run the job to create the cube. The script contains the Metadata definition of the Database and it does not contain the actual data.
Pros: Since you are only creating an empty cube the script will run faster
Cons: You still need to process the created cube to use it for reports.
Fastest option is to take the backup of the cube and restore wherever necessary.
And you can also use TFS source control to deploy the cube and process it later.
Regards,
Venkata
Venkata Koppula -
I am currently working on a SQL Server upgrade project for a a client where I am converting old dts packages to SSIS. However for a few of the packages no conversion is allowed to be done. For these few packages I have to use dts legacy components in SQL
2005 on a windows 2003 server to run them.
These packages use CAPICOM via an Active X script in the package to envelope connection string data for security within the package. Consequently I have to register the capicom.dll for the job owner (which will execute the job via proxy) and install private
and public key files via internet explorer. I also do this when I am logged in with my account so i can test the package.
I have created a SQL Server Agent Job which is used to execute the package. We have a schedule account which is local admin on the server and sysadmin within SQL Server. This account is used to create a credential and then a proxy for the CmdExec subsystem
is then created based on this credential. A CmdExec job step is then added to the job. The directory of cmd file which calls the dts package is then entered in the command window.
Finally a recurring schedule is added to execute the job every 5 minutes.
If i am logged in to the server using the scheduled account the schedule runs successfully. I am also able to run the command file manually by double clicking on it. The DTS package is run successfully. However once the schedule is set up and I log off the
machine and log onto my development machine with my normal account and fire up SQL Server. I connect to that instance with the schedule and see that the job is failing with and Active X error in the package. From experience with this package this Active
X error occurs when the user executing the package has not registered the capicom.dll. This has already been done for the scheduler account because the job runs when the scheduler account is logged in on the server.
It almost seems as though the job will only run if the Scheduler account is logged on. If i log directly on to the server with own user account I am able to manually execute the package via the cmd file which indicates that the capciom.dll is registered
under my account. Yet if I try an run the job in SQL Server when I am logged in under my account (using the scheduler account proxy) then the job fails.
Does anybody have any idea why this may be happening? Any ideas would be much appreciatedRun the job SSIS step under a proxy account that is derived from the domain account, non-expiring password and has been set to have all the necessary rights.
How to is here: http://www.mssqltips.com/sqlservertip/2163/running-a-ssis-package-from-sql-server-agent-using-a-proxy-account/
Arthur
MyBlog
Twitter -
SQL Server Version running SSIS Package
I´m trying to run an SSIS 2013 Package in SQL Server 2014 but i keep getting the error "package migration from version 8 to version 6 failed with error".
So i ckecked the vertion in SQL Server 2014 using a T-SQL query:
SELECT @@VERSION
and i got:
"Microsoft SQL Server 2012 (SP1) - 11.0.3153.0 (X64) Jul 22 2014 15:26:36 Copyright (c) Microsoft Corporation Enterprise Edition: Core-based Licensing (64-bit) on Windows NT 6.1 (Build 7601: Service Pack 1) "
The response for this query should be SQL Server 2014, right?
What should i do to alter this?I think what you meant was SSIS package created using VS 2013. If yes, it will work only on SSIS 2014 server. What you've there is SQL/SSIS 2012 version as shown by @@VERSION result
http://blogs.msdn.com/b/analysisservices/archive/2014/04/03/sql-server-data-tools-business-intelligence-for-visual-studio-2013-ssdt-bi.aspx
SO you should be using SSIS 2014 if you want to deploy the packages
Otherwise use VS 2010 or 2012 SSIS templates for deploying to 2012 server
Please Mark This As Answer if it solved your issue
Please Mark This As Helpful if it helps to solve your issue
Visakh
My MSDN Page
My Personal Blog
My Facebook Page -
.rdl file for ssis package execution reports.
Can I get a .rdl file for the SSIS Packages execution report which shows execution timing status and etc.. .where it stores (location) and possibility of the Stored procedure for the .rdl file
Not sure where the SQL Server is storing the .rdl file for the above mentioned reports. But if you just want to get summary of ETL execution you can use something similar to below query and create your own report in SSRS.
SELECT e.executable_id AS [ID] , CASE es.execution_result when 0 then 'Success' when 1 then 'Failure' when 2 then 'Completion' when 3 then 'Cancelled' END AS [Status] , ex.folder_name AS [FolderName] , ex.project_name AS [ProjectName] , e.package_name AS [PackageName] , CONVERT(datetime, es.start_time) AS [StartTime] , CONVERT(datetime, es.end_time) AS [EndTime] , CAST(es.execution_duration AS float)/1000 AS [Duration]FROM catalog.executables e INNER JOIN catalog.executable_statistics es ON e.executable_id = es.executable_id AND e.execution_id = es.execution_id INNER JOIN catalog.executions ex ON e.execution_id = ex.execution_id AND es.execution_id = ex.execution_idWHERE package_path = '\Package'ORDER BY StartTime DESC
More info can be found
here. -
Hi ,
While scheduling SSIS package i am getting following issue can anyone help me how to overcome or fix this problem
The package failed to load due to error 0xC0010014 "One or more error occurred. There should be more specific errors preceding this one that explains the details of the errors. This message is used as a return value from functions that encounter errors.".
This occurs when CPackage::LoadFromXML fails.
ADDITIONAL INFORMATION:
The package failed to load due to error 0xC0010014 "One or more error occurred. There should be more specific errors preceding this one that explains the details of the errors. This message is used as a return value from functions that encounter errors.".
This occurs when CPackage::LoadFromXML fails.
Niraj SevalkarHi,
Are you trying to import a different version into the Wrong server. i means are you trying to
import a 2008R format package onto a 2005 server. You cant do that.
Regards, PS -
Issue in using SQL Authentication in child SSIS packages from Parent SSIS package.
I am trying to provide SQL Authentication mode and credentials at parent package and I am using some child pachnages been called from this package.
How can I resolve this to use SQL authentication.
I am using 2008 Version
Thanks
Sreenath
Sreenath G VHi Sreenath,
What issue did you encounter when run the parent package? It should work properly if the SQL Server Authentication is already enabled on the target SQL Server instance and the SQL account credentials are input correctly in the child package.
You may encounter issue if you have enabled Package Configurations for the child pages that use SQL Server authentication and selected to expose the UserName and Password for the SQL Server connection. In this situation, the password won’t be exposed to
the package configurations explicitly, hence, the Dtexec utility cannot fetch the password for the connection and fails the package execution. If it is the issue, you have to specify the password for the SQL Server account in the package configurations file.
Regards,
Mike Yin
TechNet Community Support -
SQL job containing a SSIS package
Hi,
I'm trying to run a job that executes a SSIS package.
Some of the blocks in the SSIS package refers to files stored on network folders.
Each time i run the job manually i get an error message saying that the file can not be opened because it is already opened or because i have no permission to access it.
If i move the file to a local folder and change the SSIS package accordingly than the job runs fine.
what settings should i change in order for the job to be able to access the network folder?
Thanks, UdiHi
Check the account which executes the job has access permission on the network folder.
thanks
Mushtaq -
SQL AGENT JOB FOR DISK SPACE USAGE ALERT
Hello Experts
what is the best way to set up a disk space usage alert for my sql server 2008r2 databases. i want to get a notification or alert whenever the disk usage is >80%, thank you as usual.Hi
You can use sql server job for same. I am using below procedure configured with sql job running every 15 mins
Example: EXEC [DBA_DiskSpaceMntr]
@mailto = 'team mail',
@CDrivethreshold = 1024,
@OtherDrivethreshold = 10240
CREATE PROCEDURE [dbo].[DBA_DiskSpaceMntr]
@mailto nvarchar(4000),
@CDrivethreshold INT,
@DDrivethreshold INT,
@YDrivethreshold INT,
@OtherDrivethreshold INT
AS
BEGIN
declare @count int;
declare @DiskFreeSpace int;
declare @tempfspace int;
declare @tempdrive char(1);
declare @mailbody nvarchar(4000);
declare @MailSubject nvarchar(1000);
declare @AlertMessage nvarchar(4000);
declare @altflag bit;
declare @sub nvarchar(4000);
declare @cmd nvarchar(4000);
set @count = 0;
SET @mailbody = '';
SET @cmd = '';
set nocount on
IF EXISTS(select * from sys.sysobjects where id = object_id('#driveinfo'))
drop table #driveinfo
create table #driveinfo(id int identity(1,1),drive char(1), fspace int)
insert into #driveinfo EXEC master..xp_fixeddrives
SELECT @DiskFreeSpace = fspace FROM #driveinfo where drive in ('C')
IF @DiskFreeSpace < @CDrivethreshold
Begin
SET @MailSubject = 'Drive C: free space is low on ' + cast(Serverproperty('Machinename') as nVarchar)
SET @mailbody = 'Drive C: on ' + cast(Serverproperty('Machinename') as nVarchar) + ' has only ' + CAST(@DiskFreeSpace AS VARCHAR) + ' MB left. Please free up space on this drive. '
--select * FROM #driveinfo where drive in ('L')
EXEC msdb.dbo.sp_send_dbmail
@profile_name = 'SQLDBA_Support',
@recipients= @mailto,
@subject = @MailSubject,
@body = @mailbody,
--@file_attachments = @logfile,
@body_format = 'HTML'
End
SELECT @DiskFreeSpace = fspace FROM #driveinfo where drive in ('D')
IF @DiskFreeSpace < @DDrivethreshold
Begin
SET @MailSubject = 'Drive D: free space is low on ' + cast(Serverproperty('Machinename') as nVarchar)
SET @mailbody = 'Drive D: on ' + cast(Serverproperty('Machinename') as nVarchar) + ' has only ' + CAST(@DiskFreeSpace AS VARCHAR) + ' MB left. Please free up space on this drive. '
EXEC msdb.dbo.sp_send_dbmail
@profile_name = 'SQLDBA_Support',
@recipients= @mailto,
@subject = @MailSubject,
@body = @mailbody,
--@file_attachments = @logfile,
@body_format = 'HTML'
End
SELECT @DiskFreeSpace = fspace FROM #driveinfo where drive in ('Y')
IF @DiskFreeSpace < @YDrivethreshold
Begin
SET @MailSubject = 'Drive Y: free space is low on ' + cast(Serverproperty('Machinename') as nVarchar)
SET @mailbody = 'Drive Y: on ' + cast(Serverproperty('Machinename') as nVarchar) + ' has only ' + CAST(@DiskFreeSpace AS VARCHAR) + ' MB left. Please free up space on this drive. '
EXEC msdb.dbo.sp_send_dbmail
@profile_name = 'profile_name',
@recipients= @mailto,
@subject = @MailSubject,
@body = @mailbody,
--@file_attachments = @logfile,
@body_format = 'HTML'
End
set @mailbody='';
while (select count(*) from #driveinfo ) >= @count
begin
set @tempfspace = (select fspace from #driveinfo where id = @count and drive not in ('C','Q','D','Y'))
set @tempdrive = (select drive from #driveinfo where id = @count and drive not in ('C','Q','D','Y'))
if @tempfspace < @OtherDrivethreshold
BEGIN
SET @altflag = 1;
SET @mailbody = @mailbody + '<p>Drive ' + CAST(@tempdrive AS NVARCHAR(10)) + ' has ' + CAST(@tempfspace AS NVARCHAR(10)) + ' MB free</br>'
--SET @cmd = 'dir /s /-c ' + @tempdrive + ':\ > ' + @logfile
--EXEC xp_cmdshell @cmd
END
set @count = @count + 1
end
IF (@altflag = 1)
BEGIN
SET @sub = 'Monitor Space on ' + cast(Serverproperty('Machinename') as nVarchar)
set @mailbody = 'The below drives on ' + cast(Serverproperty('Machinename') as nVarchar) + ' have low disk space then threshold limit ' + CAST(@OtherDrivethreshold as VARCHAR(10)) +' Please free up the space in below specified drives <p>' + @mailbody
--print 'Space on ' + @tempdrive + ': is very low: ' + str(@tempfspace)+ 'MB'
EXEC msdb.dbo.sp_send_dbmail
@profile_name = 'Profile name',
@recipients= @mailto,
@subject = @sub,
@body = @mailbody,
--@file_attachments = @logfile,
@body_format = 'HTML'
END
drop table #driveinfo
set nocount off
END
Thanks Saurabh Sinha
http://saurabhsinhainblogs.blogspot.in/
Please click the Mark as answer button and vote as helpful
if this reply solves your problem
Maybe you are looking for
-
Can't get Flash to work in my IE 9
I Can't get Flash to work in my IE 9. I have gone through the other fixes from this site, but still can't get it to work. Any suggestions?
-
Applescripting properties within paragraph style (ID CS3)
I have as script which creates a new paragraph style - nice, but would like to be able to set it up to include fonts, colors, tabs, indents, etc... any ideas?
-
I ordered my MacPro on 8/9 with the AT1900XT and Airport card and it finally came today! I took the option at setup to transfer my data from my old iMac to my new MacPro and was really looking forward to working with it tonight. But when it went to r
-
I have a very simple Applescript saved and set to run via a Mail rule when it receives a certain type of message: tell application "iTunes" try set alarm_playlist to user playlist "Alarms" play alarm_playlist end try end tell Whenever this is called,
-
Vendor evaluation points automatic criteria
Hi How the percencetage & points are determined for automatic criteria. Regards Umapathy