Questions tagged [sql-agent-job]

this tag is used to discuss about the issues are occurred when add or modify the job steps, schedules, alerts, and notifications of sql server agent jobs.

SQL Server Agent job can be create in SQL Server by using SQL Server Management Studio, Transact-SQL, or SQL Server Management Objects (SMO).

421 questions
2
votes
1 answer

Execute SQL task works in developer and SSMS but errors out in SQL Server Agent

This code works in the SSIS editor, SSMS and running from the catalog. Here is the code: declare @maxDate as date select @maxDate = cast(max([Date]) as date) from [dbo].[sometable] --print @maxDate declare @currDate as date select @currDate =…
Kevin
  • 21
  • 1
2
votes
1 answer

Using a variable to process all *.xml files using SSIS

I am new to SSIS package, so any help would be really appreciated. The SSIS code was built using the VS2005 and its setup as a SQL agent Job in the 2005 SQL Server. Now as we are migrating to 2016 SQL server we see that the same SQL agent Job…
DataWrangler
  • 1,804
  • 17
  • 32
2
votes
1 answer

Get SQL Agent job status without polling?

I'm trying to find a way to have the SQL Server 'SQL Agent' run a particular piece of code on job step events. I had hoped that there was a way using SMO to register a callback method so that when job steps begin or change status, my code is called.…
JSacksteder
  • 780
  • 2
  • 7
  • 21
2
votes
1 answer

SQL Agent Job output in text file formatting

I am trying to write an output of SQL Agent Job to the text or excel or CSV file. But it's writing all over it's making it very huge file with white spaces and line like '-------'see below pic. I tried trimming, removing special characters. Here is…
user2040021
  • 309
  • 3
  • 15
2
votes
2 answers

SQL server jobs precedence

I have a situation where I have a job that runs every day (Job A), job that runs every 2 days (Job B) and another job that runs every weekend (Job C). I need to make sure that Job A runs before Job B. If Job A does not run appropriately then i don't…
Mutai
  • 125
  • 1
  • 1
  • 9
2
votes
1 answer

Stored procedure execution different when scheduled vs executed manually

I have a series of stored procedures that first does an ETL process, then load the results of some formulas into a new table. At the end of the process, I have a small section of code that compares the output table to the input table to make sure…
Matt
  • 4,140
  • 9
  • 40
  • 64
2
votes
1 answer

Which Account is Picked to Run SQL Server Job When Run As is Empty

I have a job agent to execute multiple steps. Each step's Run As is empty. Does that mean the job will run as job owner's account or the local system account?
Don
  • 1,532
  • 4
  • 24
  • 47
2
votes
1 answer

SQL Server Agent jobs running even though I disabled the schedule in script

I need to disable all jobs running on a server. I ran the following code: declare @t table (schedule_id int, [name] varchar(300)) update msdb.dbo.sysschedules set enabled = 0 output inserted.schedule_id, inserted.name into @t …
Quicksilver
  • 295
  • 4
  • 16
2
votes
2 answers

Where to find date & time of currently running SQL agent job STEP?

I want to query a view or table for the currently running SQL agent job steps and when did they start. I've tried queries below but it gives me JOB datetime rather then step datetime. select top 100 * from msdb.dbo.sysjobsteps select top 100 * from…
BI Dude
  • 1,842
  • 5
  • 37
  • 67
2
votes
2 answers

Microsoft Excel cannot access the file on Windows Server 2012

I am running an SSIS Package that contains a C# Script which formats an Excel File on Windows Server 2012 R2. When I run the package it gives me this error Microsoft Office Excel cannot access the file '\\FolderPath\FilePath' I have seen this…
Alexander
  • 313
  • 7
  • 20
2
votes
1 answer

Running Sql Server Agent Jobs from C#

While searching on above topic in the internet, I found two approaches,Both are working fine, But I need to know the difference between the two, Which one is suitable for what occasion etc... Our Jobs take some time and I need a way to wait till the…
Rasika
  • 312
  • 1
  • 7
  • 19
2
votes
3 answers

INSERT INTO results_table EXEC sproc from within a scheduled job

I'm trying to setup a scheduled job that with one step that would insert the results from a sproc into a table. INSERT INTO results_table EXEC sproc The job executes and reports a success. Yet nothing gets inserted into a table. When I execute the…
sumek
  • 26,495
  • 13
  • 56
  • 75
2
votes
3 answers

SQL Agent Job doesn't execute SSIS package, but doesn't fail

I set up a job to run a SSIS package in the SSIS Catalog, but the SSIS package doesn't start. If I right-click the package and run it, it completes successfully. When I look in the execution history of the package in the Catalog, there is no sign…
confusedKid
  • 3,231
  • 6
  • 30
  • 49
2
votes
1 answer

Stored procedure runs successfully but fails when called from a job

I'm running into a very bizarre error in SQL that I would like some help with. The code below creates the two stored procedures I need for this report: USE [ONDTTEST] SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE PROCEDURE…
2
votes
1 answer

Stored Procedure Fails on Converting Datetime Only When Ran From SQL Agent Job

Problem Executed as user: CORP\SVC-UK-SVCEMI. Conversion failed when converting date and/or time from character string. [SQLSTATE 22007] (Error 241). The step failed. The problem I am facing is that I have created a Stored Procedure which, when…
Scott Allen
  • 513
  • 2
  • 13