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).

383 questions
16
votes
2 answers

How execute exe file from sql agent or job?

I don't want to hit the database frequently based on page request, so I planned to create a xml file using separate C# coding [exe file] & put in the common path to access from different page/project, which will do the hitting stuff's daily morning,…
user1531248
  • 451
  • 1
  • 5
  • 14
13
votes
3 answers

Run C# code inside a SQL Agent Job

I have a piece of code that needs to run every day at a specified time. The code right now is sitting as a part of my web application. There are 2 stored procedures to get/save data that the code uses. How can I setup Microsoft SQL Server…
Tom
  • 1,017
  • 3
  • 22
  • 43
13
votes
1 answer

How to Partition a Table by Month ("Both" YEAR & MONTH) and create monthly partitions automatically?

I'm trying to Partition a Table by both Year and Month. The Column through which I'll partition is a datetime type column with an ISO Format ('20150110', 20150202', etc). For example, I have sales data for 2010, 2011, 2012. I'd Like the data to be…
Amr Tharwat
  • 231
  • 1
  • 2
  • 10
10
votes
3 answers

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

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,…
DarinH
  • 4,768
  • 2
  • 20
  • 32
10
votes
1 answer

SQL Maintenance Plan sends mail when no mail configured

I have a Maintenance plan under SQL Server 2008 R2 which runs at midnight. Within this maintenance task, there is no notify operator task. Within the SQL Agent job that executes the maintenance plan, there is no email alert. However, every time this…
10
votes
3 answers

SQL Agent Job: Determine how long it has been running

The Scenario There are certain SQL Agent Jobs that are scheduled to run every few minutes throughout the day. There are legitimate times when it will miss its next schedule because it's still running from the previous schedule. Every once and a…
Kevin Fairchild
  • 10,501
  • 6
  • 30
  • 51
10
votes
5 answers

Need to start agent job and wait until completes and get success or failure

I have been trying to find sample code with using SQL Server 2005, I need to start an Agent Job and wait until it finishes process and then get the success or failure. I know that I can use EXEC MSDB.dbo.sp_start_job @Job_Name = 'JobName' to…
user31673
  • 11,875
  • 12
  • 55
  • 95
10
votes
3 answers

How to pass a parameter to a SQL Job that will execute a stored procedure

I have the below code (only the portion that is needed) EXEC @ReturnCode = msdb.dbo.sp_add_jobstep @job_id=@jobId, @step_name=N'SomeStep', @step_id=1, @cmdexec_success_code=0, @on_success_action=1, …
user1323981
7
votes
4 answers

SQL Server Agent Job Running Slow

I am executing a stored procedure using SQL Server Agent Job in SQL Server 2005. This job was running fast until yesterday. Since yesterday this job is taking more than 1 hour instead of 2 mins. I executed the stored procedure in SSMS, it just…
Prateek
  • 231
  • 3
  • 6
  • 12
6
votes
5 answers

SQL Server Agent - get my own job_id

I'm running a SQL Server 2008 64 bit Developer Edition with Service Pack 1 installed. I have a SQL Server Agent Job. Within this job I want to get the job_id of my own job. On MSDN (http://msdn.microsoft.com/en-us/library/ms175575(v=SQL.100).aspx)…
6
votes
1 answer

SQL Server Agent not starting automatically on server reboot

I have noticed that SQL Agent does not start automatically after a reboot/shutdown on a few of our servers (SQL server starts up fine). The service is set to automatically start in windows. When we start SQL agent manually, it starts fine.
6
votes
2 answers

How to Export data to Excel in SQL Server using SQL Jobs

I need to export the data from a particular table in my database to Excel files (.xls/.xlsx) that will be located into a shared folder into my network. Now the situation is like this - I need to use SQL SERVER Agent Jobs. 2.I need to generate a new…
Atanu Roy
  • 1,294
  • 2
  • 15
  • 29
6
votes
5 answers

I need best practice in T-SQL Export data to CSV (with header)

What I need to do is export data into CSV file using T-SQL. And I'm very confused about there are many ways can do it, I don't know to choose which one, please help me to confirm the bollowing: As I know there are about 3 methods, and I want you…
Guoliang
  • 825
  • 2
  • 12
  • 19
5
votes
1 answer

Query to list the job names and step associated with a particular table

Is there any way to search and find ,what job holds a particular table refresh . There are multiple sql agent jobs with multiple steps.What is the sql query to search all jobs and locate the job name and steps? This is to identify the steps…
user1254579
  • 3,546
  • 17
  • 58
  • 95
5
votes
6 answers

Empty string results in "Errors were detected in the command line arguments, please make sure all arguments are set correctly"

On a SQL 2016 Server I have a job that calls an SSIS package. That package is in a project in the SSISDB and has parameters. One of those parameters is a string type that is blank as a default. I ran the job with the blank value for this…
Tab Alleman
  • 30,501
  • 7
  • 31
  • 50
1
2 3
25 26