Scheduling SQL AGENT JOB for SSAS DataBase to take backup files Daily with Different Names

Hi All,
I am working with SSMS. I have Analysis Services DataBase.
i want to Schedule a SQL SERVER AGENT JOB.
I want to take that AS DB BackUp Daily and has to be stored in Same
Folder/same path in my local
machiene with Different Names.
Means, There should be Daily BackUps Files in that Path.  According to that we have to Schedule the JOB.
Can anyone help me for this..
Thanks,
Supraja.

 Hi Katherine,
Thanks a lot for your Response. what
you have posted is very useful for me.
But i am searching the result using AS
DataBase BackUp Script. 
i found one of the easy way. its working for me.
Please check the below link for your reference..
http://dbatasks.blogspot.in/2012/08/taking-backup-of-ssas-database.html
Thanks,
Supraja.

Similar Messages

  • How to schedule SQL Agent job for XMLA script file of SSAS database instead of taking a backup.

    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 ? 
    Amir

    Hi 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

  • Errors running SQL Agent Jobs for 64 bit SSIS packages on a 64 bit server, but Source server 32 bit

    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 knowledge

    Hi 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

  • 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.
    Thanks

    You 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

  • 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

  • SQL Agent job step - SSIS package - adding a config file - will it override the one that the package specifies?

    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

  • LcsCDR & QoEMetrics Purge and Usage Summary SQL Agent Jobs

    Hello.
    On our SQL instance that hosts the LcsCDR & QoEMetrics databases I have the following SQL Server Agent Jobs:
    LcsCDR_Purge
    LcsCDR_UsageSummary
    QoEMetrics_Purge
    QoEMetrics_UsageSummary
    I'd like to know if anyone else has these same jobs on their instances as it's unclear looking at the job descriptions, when they were created, and the code they run if these are part of the core Lync system or something that has been set up randomly
    afterwards.
    One thing I do know is that these jobs don't work correctly when you use database mirroring. I will elaborate on this if/when I can find out any more information about them first.
    Thanks

    Thank you for the reply.
    The problem with these jobs is that when they attempt to run against a database which is a mirror, it causes the job to fail. That would not seem to be a big deal right, except our policy (and many other SQL shops I imagine) is to send e-mail notifications
    each and every time a SQL agent job fails on any server, not just those associated with Lync.
    As it stands these jobs are not configured on either the principal or mirror server to notify anyone as I’d get an e-mail every hour on the hour from the mirror server telling me that a job has failed  (even though it didn’t actually need to do anything
    ) giving the impression something is wrong somewhere. This is quite a common trap to fall into with SQL Agent jobs and database mirroring.
    Remember that because as Lync uses automatic failover either server could be the mirror at any given time so there is no mileage in setting the e-mail notifications on just the server that is currently the principal.
    What this job should do then is when it attempts to run on the mirror, check if it’s the mirror first and if it is then do nothing instead of failing each time.  This will enable e-mail notifications to be set up on the jobs on both servers, so when
    the job fails we know there is potentially a genuine problem to be investigated.
    Each job contains two steps, I’ll use the QoEMetrics_UsageSummary as the example.
    The code in step 1 is this, which causes the job to error out if it is attempting to run against the mirror.
    declare @_MirroringRole int
    set @_MirroringRole = (
    select mirroring_role
    from sys.database_mirroring
    where database_id = DB_ID('QoEMetrics')
    if (@_MirroringRole is not NULL and @_MirroringRole = 2) begin
    raiserror('Database is mirrored', 16, 1)
    end
    else begin
    print ('Database is not mirrored')
    end
    I re-wrote this job to run in one-step like this, which runs from the master database, which as I mentioned above doesn’t make the job error out when it realises it’s trying to run against a mirror.
    DECLARE @_MirroringRole INT
    SET @_MirroringRole = ( SELECT mirroring_role
    FROM sys.database_mirroring
    WHERE database_id = DB_ID('QoEMetrics'))
    -- if this is not a mirrored database or it's the principal, attempt to run usage summary op
    IF (@_MirroringRole IS NULL OR @_MirroringRole = 1)
    BEGIN
    DECLARE @_Sql NVARCHAR(4000)
    SET @_Sql =
    'USE [QoEMetrics];
    DECLARE @_UpdatingSkipped INT
    EXEC dbo.RtcRegularMaintainDatabase @_UpdatingSkipped = @_UpdatingSkipped output'
    EXEC (@_Sql)
    END
    ELSE -- if the database is a mirror, don't do anything
    BEGIN
    PRINT 'there is nothing to do, the database is a mirror'
    END
    The same logic can be applied to the other 3 jobs and I was intending to suggest it as a connect item, except there doesn’t seem to be a section for Lync so I will contact product support and see what they think.
    Thanks again.

  • SQL Agent Job failing - not using credentials in the config file for Data source

    Hi
    We have an SSIS pkg, that is secheduled as SQL Agent job using proxy account. The pkg contanins data source for connecting different SQL servers and the proxy account do not have access to the external DBs. The data source credentials are stored in the Config
    file.
    Why the job is not using the credentials in the config file and try to use the proxy account and failing.
    Do the proxy account need access to all the external dbs in the pkg, and then what is the purpose of the config file.
    I am sorry, i am not SSIS person trying to understand. If any one can explain tha will be great!!
    Thank you!
    VR

    Please take a look at these URLs:
    Schedule a Package by using SQL Server Agent
    SSIS package does not run when called from a SQL Server Agent job step
    Cheers,
    Saeid Hasani
    Database Consultant
    Please feel free to contact me at [email protected] as well as on Twitter and Facebook.
    [My Writings on TechNet Wiki] [T-SQL Blog] [Curah!]
    [Twitter] [Facebook] [Email]

  • SQL agent job schedule

    Hi, 
    I have multiple  SQL agent jobs , i need to schedule these jobs to run one after other , below explanation should give you more info 
    job 1  scheduled every day @ 12 : 00  am 
    job 2 scheduled every day @ 2 : 00 am 
    job 3  scheduled every day @ 3 : 00 am
     Issue here is some times my job 2 is starting before job 1 finishes . Which is causing  problems 
    i want  job 2 run only after job 1 is done  and job 3 after job 2 and goes on 
    can some one please help how to do this ,any help will be appreciated 

    If you want the process to be sequential why not merge all of the processes into same job itself as different consecutive steps? That would be the easiest to ensure they run in sequence
    If thats not possible then way to do this is as follows
    1.Add a new first step to Job 2 and Job 3 as follows
    IF EXISTS(
    select 1
    from msdb.dbo.sysjobs_view job
    inner join msdb.dbo.sysjobactivity activity on job.job_id = activity.job_id
    where
    activity.run_Requested_date is not null
    and activity.stop_execution_date is null
    and job.name = <Previous Job Name Here>
    RAISERROR 'Previous Job Not Completed Yet!',16,1
    Replace job name correctly based on your case
    Then in advanced tab make On Failure Action as quit the job reporting failure and OnSuccessAction
    to default. Also set retry attempts to non zero number (say 10) and
    retry interval to say 15 minutes
    Once this is done Job 2 will start and keep on failing until Job 1 gets finished and it will retry itself in 15 minutes for 10 times. When Job 1 finishes in the interim the next retry will be a success and job will quit.
    Do the same for Job 3 too replacing name of the job as that of Job2
    Please Mark This As Answer if it solved your issue
    Please Vote This As Helpful if it helps to solve your issue
    Visakh
    My Wiki User Page
    My MSDN Page
    My Personal Blog
    My Facebook Page

  • Sql agent jobs based on the database and the user

    Dear All,
    I have a requirement of configuring an user who should only have access to one database out of all and also able to create, view and modify sql agent jobs only for the allowed database. For allowing to see the selected database to particular user I have
    granted permissions as per below,
    create LOGIN mhtc WITH PASSWORD='mhtc', CHECK_POLICY = OFF;
    USE master;
    GO
    DENY VIEW ANY DATABASE TO mhtc;
    USE master;
    GO
    ALTER AUTHORIZATION ON DATABASE::MHTC TO mhtc;
    GO
    but user not able to see sql agent jobs so I want to give necessary permission to this user to view,create and modify sql agent jobs only in allowed databases. Basically I want to separate users from each database and separate sql agent jobs based on the
    user and database.
    Your expert advices are highly appreciated.
    Thanks,
    Manjula

    I want to give necessary permission to this user to view,create and modify
    sql agent jobs only in allowed databases.
    Hello Manjula,
    SQL Server Agent Jobs are not created / dedicated for a user database. The Jobs are store in System database "msdb".
    See
    Implement SQL Server Agent Security for Details about required permissions.
    Olaf Helper
    [ Blog] [ Xing] [ MVP]

  • SQL Agent jobs status for multiple servers using Powershell.

    Hi All,
    I am following website link:
    http://www.toadworld.com/platforms/sql-server/b/weblog/archive/2013/09/17/powershell-script-to-monitor-a-service-on-a-group-of-servers-html-formatted-email-output.aspx
    I require to gather status details about all the SQL Agent jobs in the environment on multiple SQL Servers.
    I tried to edit the script using:
    [void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.SMO")
    $sqlServerName = 'localhost\developer'
    $sqlServer = New-Object Microsoft.SqlServer.Management.Smo.Server($sqlServerName)
    foreach($job in $sqlServer.JobServer.Jobs)
        $job | select Name, OwnerLoginName, IsEnabled, LastRunDate, LastRunOutcome, DateCReated, DateLastModified
    but SQL Agent jobs are not reflecting in the mail output...
    requesting help...!!
    Thanks in Advance.
    Hunt

    I've created a new script for you.  Let me know if you've any questions
    Create the function
    Function Get-SQLJobHTMLReport
    param(
    [String]$ComputerList,[string]$Outputfile,[String]$To,[String]$From,[string]$SMTPMail
    New-Item -ItemType file $Outputfile -Force
    # Function to write the HTML Header to the file
    Function writeHtmlHeader
    param($fileName)
    $date = ( get-date ).ToString(‘yyyy/MM/dd’)
    Add-Content $fileName “<html>”
    Add-Content $fileName “<head>”
    Add-Content $fileName “<meta http-equiv=’Content-Type’ content=’text/html; charset=iso-8859-1′>”
    Add-Content $fileName ‘<title>Service Status Report </title>’
    add-content $fileName ‘<STYLE TYPE=”text/css”>’
    add-content $fileName “<!–”
    add-content $fileName “td {“
    add-content $fileName “font-family: Tahoma;”
    add-content $fileName “font-size: 11px;”
    add-content $fileName “border-top: 1px solid #999999;”
    add-content $fileName “border-right: 1px solid #999999;”
    add-content $fileName “border-bottom: 1px solid #999999;”
    add-content $fileName “border-left: 1px solid #999999;”
    add-content $fileName “padding-top: 0px;”
    add-content $fileName “padding-right: 0px;”
    add-content $fileName “padding-bottom: 0px;”
    add-content $fileName “padding-left: 0px;”
    add-content $fileName “}”
    add-content $fileName “body {“
    add-content $fileName “margin-left: 5px;”
    add-content $fileName “margin-top: 5px;”
    add-content $fileName “margin-right: 0px;”
    add-content $fileName “margin-bottom: 10px;”
    add-content $fileName “”
    add-content $fileName “table {“
    add-content $fileName “border: thin solid #000000;”
    add-content $fileName “}”
    add-content $fileName “–>”
    add-content $fileName “</style>”
    Add-Content $fileName “</head>”
    Add-Content $fileName “<body>”
    add-content $fileName “<table width=’100%’>”
    add-content $fileName “<tr bgcolor=’#CCCCCC’>”
    add-content $fileName “<td colspan=’4′ height=’25′ align=’center’>”
    add-content $fileName “</td>”
    add-content $fileName “</tr>”
    add-content $fileName “</table>”
    # Function to write the HTML Header to the file
    Function writeTableHeader
    param($fileName)
    Add-Content $fileName “<tr bgcolor=#CCCCCC>”
    Add-Content $fileName “<td width=’10%’ align=’center’>ServerName</td>”
    Add-Content $fileName “<td width=’50%’ align=’center’>Name</td>”
    Add-Content $fileName “<td width=’10%’ align=’center’>OwnerLoginName</td>”
    Add-Content $fileName “<td width=’10%’ align=’center’>IsEnabled</td>”
    Add-Content $fileName “<td width=’10%’ align=’center’>LastRunDate</td>”
    Add-Content $fileName “<td width=’10%’ align=’center’>LastRunOutcome</td>”
    Add-Content $fileName “<td width=’10%’ align=’center’>DateCReated</td>”
    Add-Content $fileName “<td width=’10%’ align=’center’>DateLastModified</td>”
    Add-Content $fileName “</tr>”
    Function writeHtmlFooter
    param($fileName)
    Add-Content $fileName “</body>”
    Add-Content $fileName “</html>”
    Function writeDiskInfo
    param($filename,$Servername,$name,$OwnerLoginName,$IsEnabled,$LastRunDate,$LastRunOutcome,$DateCReated,$DateLastModified)
    Add-Content $fileName “<tr>”
    Add-Content $fileName “<td bgcolor=’#FF0000′ align=left ><b>$servername</td>”
    Add-Content $fileName “<td bgcolor=’#FF0000′ align=left ><b>$name</td>”
    Add-Content $fileName “<td bgcolor=’#FF0000′ align=left ><b>$OwnerLoginName</td>”
    Add-Content $fileName “<td bgcolor=’#FF0000′ align=left ><b>$IsEnabled</td>”
    Add-Content $fileName “<td bgcolor=’#FF0000′ align=left ><b>$LastRunDate</td>”
    Add-Content $fileName “<td bgcolor=’#FF0000′ align=left ><b>$LastRunOutcome</td>”
    Add-Content $fileName “<td bgcolor=’#FF0000′ align=left ><b>$DateCReated</td>”
    Add-Content $fileName “<td bgcolor=’#FF0000′ align=left ><b>$DateLastModified</td>”
    Add-Content $fileName “</tr>”
    writeHtmlHeader $Outputfile
    Add-Content $Outputfile “<table width=’100%’><tbody>”
    Add-Content $Outputfile “<tr bgcolor=’#CCCCCC’>”
    Add-Content $Outputfile “<td width=’100%’ align=’center’ colSpan=8><font face=’tahoma’ color=’#003399′ size=’2′><center><strong> SQL Server Agent Job Details</strong></font></td>”
    Add-Content $Outputfile “</tr>”
    writeTableHeader $Outputfile
    #Change value of the following parameter as needed
    Foreach($ServerName in (Get-Content $ComputerList))
    $sqlServer = New-Object Microsoft.SqlServer.Management.Smo.Server($ServerName)
    foreach($item in $sqlServer.JobServer.Jobs)
    Write-Host $sqlServer $item.name $item.OwnerLoginName $item.IsEnabled $item.LastRunDate $item.LastRunOutcome $item.DateCReated $item.DateLastModified
    writeDiskInfo $Outputfile $sqlServer $item.name $item.OwnerLoginName $item.IsEnabled $item.LastRunDate $item.LastRunOutcome $item.DateCReated $item.DateLastModified
    Add-Content $Outputfile “</table>”
    writeHtmlFooter $Outputfile
    Function sendEmail
    param($from,$to,$subject,$smtphost,$htmlFileName)
    [string]$receipients=”$to”
    $body = Get-Content $htmlFileName
    $body = New-Object System.Net.Mail.MailMessage $from, $receipients, $subject, $body
    $body.isBodyhtml = $true
    $smtpServer = $smtphost
    $smtp = new-object Net.Mail.SmtpClient($smtphost)
    $smtp.Send($body)
    write-output “Email Sent!!”
    $date = ( get-date ).ToString(‘yyyy/MM/dd’)
    sendEmail -from $From -to $to -subject “Service Status – $Date” -smtphost $SMTPMail -htmlfilename $Outputfile
    Get-SQLJobHTMLReport -ComputerList f:\powersql\server.txt -SMTPMail hq.abc.com -To [email protected] -From [email protected] -Outputfile F:\Powersql\jobs.htm
    --Prashanth

  • How can I edit the Alert Description for a SQL Agent Job monitor, specifically Job Duration.

    I'm setting up some sql agent job monitoring, I need to monitor for Job Duration. 
    This is easy enough, I just create the overrides and set the parameters and it alerts as expected, however there is no alert text. The alert does me no good with out an alert description. How can I change this?
    Paul Arbogast

    Paul
    It is not an easy way for your just copy that monitor and modify it. If you has interest, you may use MP2XMLDumper tool to export SQL server monitoring MP , modify relate moniotr and import it into SCOM.
    You can download  MP2XMLDumper tool  from
    http://blogs.technet.com/b/cliveeastwood/archive/2007/08/22/mp2xmldumper-version-2-0-export-opsmgr-mp-s-to-xml-using-mp-name-export-criteria.aspx 
    Roger

  • SQL Agent Job Notification - Database Mail problem

    Hi
    I'm a little stumped. Have setup database mail on SQL Server 2008 (SP1 x64) and its working fine except when its supposed to send out a SQL Agent job notification.
    I've enabled database mail on SQL Agent and have specified a profile, but when it tries to send an email on agent job completion it errors with "NOTE: Failed to notify '<operator>' via email."
    Can anybody help?
    Thanks

     Hi Webdawg, 
      As suggested above, try these steps.
     1. Try  test email first, this can be by done (right click on database mail under mangement folder). prior to that you should already have a profile configured to send the emails and make sure you got the right SMTP server and  do not block
    port 25.
    2.If test is succeeds, enable mail option under sql server agent properties and select 'database mail' and corresponding profile.Add the reciepents email to the operators under sql server agent(check the enabled option here). Restart the SQL sever
    here.
    3. Create your sql job and in the notifcations section you should see email option and should have the operator email you configured above.
    Try it out. let us know. Hope it helps.
    If the test succeeds and still you did not get the email from sql job, check the database mail log and check whether it is being queued. let us know. 
    Please mark as 'Answer', if the solution solves your problem.

  • How to retrive error message for sql agent job failure

    My sql server agent job failed and didn't store any error message in the job history. Is there any other table from where I can get the error info????
    The job has sql_message_id = 16389 and sql_severity = 16. What does they mean????

    this link will solve your problem
    http://www.sqlservercentral.com/articles/SQL+Server+Agent/67726/
    ebro
    CREATE PROCEDURE pr_GetStepFailureData
    @JobName VARCHAR(250)
    AS
    This procedure gets failure log data for the failed step of a SQL Server Agent job
    DECLARE @job_id UNIQUEIDENTIFIER
    SELECT @job_id = job_id FROM dbo.sysjobs WHERE [name] = @JobName
    SELECT 'Step ' + CAST(JH.step_id AS VARCHAR(3)) + ' of ' + (SELECT CAST(COUNT(*) AS VARCHAR(5)) FROM dbo.sysjobsteps WHERE job_id = @job_id) AS StepFailed,
    CAST(RIGHT(JH.run_date,2) AS CHAR(2)) + '/' + CAST(SUBSTRING(CAST(JH.run_date AS CHAR(8)),5,2) AS CHAR(2)) + '/' + CAST(LEFT(JH.run_date,4) AS CHAR(4)) AS DateRun,
    LEFT(RIGHT('0' + CAST(JH.run_time AS VARCHAR(6)),6),2) + ':' + SUBSTRING(RIGHT('0' + CAST(JH.run_time AS VARCHAR(6)),6),3,2) + ':' + LEFT(RIGHT('0' + CAST(JH.run_time AS VARCHAR(6)),6),2) AS TimeRun,
    JS.step_name,
    JH.run_duration,
    CASE
    WHEN JSL.[log] IS NULL THEN JH.[Message]
    ELSE JSL.[log]
    END AS LogOutput
    FROM dbo.sysjobsteps JS INNER JOIN dbo.sysjobhistory JH
    ON JS.job_id = JH.job_id AND JS.step_id = JH.step_id
    LEFT OUTER JOIN dbo.sysjobstepslogs JSL
    ON JS.step_uid = JSL.step_uid
    WHERE INSTANCE_ID >
    (SELECT MIN(INSTANCE_ID)
    FROM (
    SELECT top (2) INSTANCE_ID, job_id
    FROM dbo.sysjobhistory
    WHERE job_id = @job_id
    AND STEP_ID = 0
    ORDER BY INSTANCE_ID desc
    ) A
    AND JS.step_id <> 0
    AND JH.job_id = @job_id
    AND JH.run_status = 0
    ORDER BY JS.step_id
    EXEC pr_GetStepFailureData 'JobName'

  • Suggestions for how to execute file maintenance in SQL Agent Job

    I need to create a SQL Agent Job (it has to be a SQL agent job) to zip all files in a directory, delete all files in the directory but the zip file and then copy the zip file to another location across a UNC path. What are some suggestions for getting
    this done? 
    Thanks.

    This is about a previous topic ...
    "1. Please close your preview thread by marking the answers that you got and not your own summary. Actualy you can mark your summary as well if you feel that this close the thread but yet, this is a summary of the answers that you got! People
    that help you Invested time to help you. Feel free to
    not be lazy and start you can start voting helpful responses as well :-)"
    How do you mark useful answers? I have not seen how to do that.
    On the left of each response you have an icon (small image).
    I have asked lots of questions on the TechNet and other forums. (One day I hope to even answer some.) That was the first time I had ever marked my own as the answer. Honestly, I did not use any of those well meaning replies and did not feel that any of them
    answered my question. When researching a topic I, like most people, I look at the marked answer first and assume it is the answer. Did not feel that  any of them were the answer. There is a great push on this forum to mark the answer and there are droves
    of people clamoring for points (BTW - you are not one of them). I review each of my questions, always follow up on any  replies, post my solution if appropriate, and always try to close the topic. But this one was not answered.
    OK, that is logic, If you dont think that you use other response as part of the answer. In my opinion (and you dont have to get it) if an answer is build from 3 responses together then we need to mark all the three (and mentioned in the summery what we have
    done). If you find that those response cant be called "answer" since they do not cover enough then maybe your call was correct.
    Please close the thread in the way that you feel is OK :-)
    (you dont have to accept my opinion since you have your explanation, but i do think that some of the responses there are answers).
    [Personal Site] [Blog] [Facebook]

Maybe you are looking for

  • How to infer values in characteristics of material

    Hi Experts I am trying to infer a characteristic (manufacturer name) based on another characterisitc (manufacturer number) for material master. I have done the following steps: -created the characteristic (single value, Additional Value ticked, Not R

  • Where can I find an Owner's Manual for my new MacBook Pro?

    Where can I find an Owner's Manual for my new MacBook Pro?

  • Transfer intenal table to file

    Hi abaers, i need to transfer the internal table data to file,,this file to create in application server. internal table lineitems contains 100 fields... i tried in the following method: but 100 fields i have to move each and evry field to t_output-d

  • How do I get a Stable pdf to Google Documents?

    i am posting a pdf created in Mac Pages to Google Documents and the font is getting changed. Is there a way to open this document in my new version of Acrobat Pro and save it out so that the font won't change? TIA!

  • BT Yahoo Toolbar and Windows Live Mail password se...

    I have been puzzling yet again why my auto log in to Windows Live Mail no longer works. Although I tick "remember me", after a reboot I am asked for my password again. I then came upon this link: http://www.i19777.net/forum/showthread.php?t=2169 It s