sql-server-agent

SQL Server Agent Job Notify multiple operators on failure

谁说胖子不能爱 提交于 2019-12-10 00:36:32
问题 I have a Job setup in SQL Server 2008 which sends a notification email to one operator when the job fails. Question: Is it possible to setup a notification email being sent to multiple operators for that specific job? I believe a possible workaround for this is to create lots of alerts for the database for each given severity but I was hoping that there was a more concise way to do this. If I were to go this route, what severity errors would likely be triggered from a failed job? (I don't

The SELECT permission was denied on the object 'sysjobs', database 'msdb', schema 'dbo'

自古美人都是妖i 提交于 2019-12-09 13:22:59
问题 I'm getting the following error when trying to read a SQL Job. The SELECT permission was denied on the object 'sysjobs', database 'msdb', schema 'dbo' How can I fix this? 回答1: You need to GRANT the SELECT permission for the user of your job. A simple GRANT . USE pubs GO GRANT SELECT ON authors TO public GO Further information about GRANT 回答2: You use the "SQL Server Agent Fixed Database Roles" in msdb (MSDN link): don't assigned permission directly, it'll be a pain to manage And a "how to"

How to accurately detect if a SQL Server job is running and deal with the job already running?

余生颓废 提交于 2019-12-08 15:59:16
问题 I'm currently using code like this to detect if a SQL server job is running. (this is SQL Server 2005, all SP's) return (select isnull( (select top 1 CASE WHEN current_execution_status = 4 THEN 0 ELSE 1 END from openquery(devtestvm, 'EXEC msdb.dbo.sp_help_job') where current_execution_status = 4 and name = 'WQCheckQueueJob' + cast(@Index as varchar(10)) ), 1) ) No problems there, and generally speaking, it works just fine. But.... (always a but) On occasion, I'll invoke this, get back a "job

strange scripts generated by SQL Server when exporting a job

流过昼夜 提交于 2019-12-08 06:05:23
问题 I am using SQL Server 2008 Enterprise. I am using Management Studio -> Jobs -> Script Job as -> Drop and Create TO feature to generate related sql statement so that from another computer I can import the job. My question is, from the generated sql scripts, from the beginning there is output like this, there is a hard coded jobid -- @job_id=N'3c5f83cd-e220-49ee-a1f1-40e37713ba1b'. My confusion is if we dependent on such hard coded value, on another computer maybe jobid is a different value...

SSIS package not running when called as step in SQL Job

醉酒当歌 提交于 2019-12-07 17:47:07
问题 I have a .dtsx file (an SSIS package) that downloads files from an FTP server and imports data. It runs fine whenever I run it manually. However, when I schedule calling the package as a step in a SQL server agent job, it fails. The step it fails at is the one where I call a .bat file. The error in the job history viewer says this: Error: 2009-05-26 12:52:25.64 Code: 0xC0029151 Source: Execute batch file Execute Process Task Description: In Executing "D:\xxx\import.bat" "" at "", The process

strange scripts generated by SQL Server when exporting a job

时光毁灭记忆、已成空白 提交于 2019-12-06 14:53:21
I am using SQL Server 2008 Enterprise. I am using Management Studio -> Jobs -> Script Job as -> Drop and Create TO feature to generate related sql statement so that from another computer I can import the job. My question is, from the generated sql scripts, from the beginning there is output like this, there is a hard coded jobid -- @job_id=N'3c5f83cd-e220-49ee-a1f1-40e37713ba1b'. My confusion is if we dependent on such hard coded value, on another computer maybe jobid is a different value... So importing into another computer may fail? USE [msdb] GO IF EXISTS (SELECT job_id FROM msdb.dbo

How to start SQL Server agent jobs automatically

霸气de小男生 提交于 2019-12-06 06:36:59
I am writing PowerShell scripts to control SQL Server agent start/stop to ensure all the contained jobs runs according to defined schedule. I want to make sure that the only thing I need to do is to start the SQL Server Agent Windows Service, and then all the contained SQL Server Jobs will run automatically according to defined schedule? No need to control each job's start/stop specifically? I am using SQL Server 2008 on Windows Server 2003. thanks in advance, George When you start SQL Server Agent all jobs (if they are not disabled) will run automatically and it's no need to control each job.

Run a 32 bit Powershell script on Sql Server Agent

南楼画角 提交于 2019-12-06 03:34:34
I have a powershell script that runs a 32 bit com object so when I run it in Powershell 64x it fails but runs fine in 86x When I run it in a Sql Server Agent job it has the same 64x failure. Is there a way around this? Like SSIS packages? You can directly invoke the 32-bit version of PowerShell by calling it through the WOW64 path: %SystemRoot%\syswow64\WindowsPowerShell\v1.0\powershell.exe Using the -File command line argument you can pass the name of the script you would like to run. 来源: https://stackoverflow.com/questions/10253543/run-a-32-bit-powershell-script-on-sql-server-agent

SSIS package not running when called as step in SQL Job

Deadly 提交于 2019-12-06 01:32:55
I have a .dtsx file (an SSIS package) that downloads files from an FTP server and imports data. It runs fine whenever I run it manually. However, when I schedule calling the package as a step in a SQL server agent job, it fails. The step it fails at is the one where I call a .bat file. The error in the job history viewer says this: Error: 2009-05-26 12:52:25.64 Code: 0xC0029151 Source: Execute batch file Execute Process Task Description: In Executing "D:\xxx\import.bat" "" at "", The process exit code was "1" while the expected was "0". End Error DTExec: The package execution returned DTSER

Get date of last successful job run?

对着背影说爱祢 提交于 2019-12-05 03:26:48
I have a single step job that executes a stored procedure. I would like get the date of the last successful job execution time so that I can just update a delta instead of the whole set of data. Right now I have the job setup to run once every day, so I have a default parameter that if it's null I set it to GETDATE() - 1 so I'm still updating a delta but what I'd like to do is set the date to the last successful execution of the job. exec dbo.usp_UpdateFrom @LastSuccessfulExecutionTime Current procedure is something like CREATE PROCEDURE dbo.usp_UpdateFrom @FromDate datetime = NULL --would