Quantcast
Channel: Questions in topic: "sql-agent"
Viewing all 80 articles
Browse latest View live

SQL Agent Scheduling to run on specific days.

$
0
0
Hello! I need to schedule a job to run on the 1st of month ,31st and Monday(excluding the near Mondays for first of month and end of month). So for November 2015 it will be executed on the 1st,9 th,16 th,23rd and 30. Appreciate any suggestions Thanks

How SQL Jobs will work in always ON configuration?

$
0
0
As per my understanding "Always ON" configuration internally have two nodes and active node will always serve the request. But suppose I have SQL Jobs in these nodes then how can I enable/disable these jobs based on active node? Kindly provide the best practises.

How to find who has modified maintenace plan backupjobs?

$
0
0
Hi folks, Recently we had a trouble, in Maintenace plan for backup jobs we configured as retention period of older than 4 weeks jobs has to be deleted automatically. but someone has changed the rention period as 3 weeks. we are not able to found out who has modified the plan? Is there any query has available to modified time,login details has modified the plan? I checked this query: select * from sysmaintplan_logdetail select * from sysmaintplan_log select * from msdb..sysmaintplan_plans (nolock) select * from msdb..sysmaintplan_subplans not having those information...kindly clarify my doubts. Regards stephen

Unable to execute the same query by some connections to the database among 5 connections

$
0
0
i had 5 connections to the database(sqlserver2012)among first 2 connections executed the connections and 3rd connection failed to execute the same query. 2016/04/28 20:03:39 普通: Creating statement Done 2016/04/28 20:03:39 普通: Executing query of Select COUNT(*) from metriclistinfo 2016/04/28 20:03:39 普通: Executing next function on ResultSet object 2016/04/28 20:03:39 普通: Returned no of rows8 2016/04/28 20:03:39 普通: Executing query ofSelect * from metriclistinfo 2016/04/28 20:03:39 普通: Data available in resultset2 : APPLICATIONIndex0 2016/04/28 20:03:39 普通: Data available in resultset2 : GLOBALIndex1 2016/04/28 20:03:39 普通: Data available in resultset2 : SYSDOWNTIMEIndex2 2016/04/28 20:03:39 普通: Data available in resultset2 : TRANSACTIONSIndex3 2016/04/28 20:03:39 普通: Data available in resultset2 : UPTIMEIndex4 2016/04/28 20:03:39 普通: Data available in resultset2 : VM_CONFIGIndex5 2016/04/28 20:03:39 普通: Data available in resultset2 : VM_GLOBALIndex6 2016/04/28 20:03:39 普通: Data available in resultset2 : VM_LOGICALIndex7 2016/04/28 20:03:39 普通: Creating statement Done 2016/04/28 20:03:39 普通: Executing query of Select COUNT(*) from metriclistinfo 2016/04/28 20:03:39 普通: Executing next function on ResultSet object 2016/04/28 20:03:39 普通: Returned no of rows8 2016/04/28 20:03:39 重大: Exception while getting metadata from source:Unknown data type:78

Needing help outputing Sql report to .csv to network folder

$
0
0
I have a sql report that I have scheduled to run every day within the SQL 2008 R2 - SQL Service Agent. My problem is, I need the output for Sql report to automatically download as a comma delimited file to a folder on our local network. What is the easiest way for me to accomplish this?

SSRS Subscription run causing locking of the tables and results in SQL Agent job failure

$
0
0
I have one SSRS report which has been scheduled to run first 10 days of every month and has been in place since 2015 but from last week onwards, the scheduled report subscription run had been taking around 2 hours to complete processing which normally take max 10 minutes. this is also causing issues with the SQl Agent job failure as the table which are being queried by the report run are getting locked and the SQL Agent job is unable to access those tables and getting failed with Time Out error. when Subscription run is completed, all the jobs run within the time without any errors. I had checked the data set queries for the report, and in some of the data set queries there are WITH(NOLOCK) options defined with the Table definition but not in all the data set queries. I am not really looking for defining the WITH(NOLOCK) options in every data set as this gives dirty reads but any locking strategy that can be used in SSRS Report which can prevent the SQL agent jobs to fail when subscription runs. i even tried enabling **READ_COMMITTED_SNAPSHOT ON** on the database where my tables are present and are being queried but this resulted in the Subscription processing errors though the SQL Agent jobs didn't fail during the subscription run. i am looking for any lock mode that can be set at the query level or on the connection string or any other option. NOLOCK is not necessarily the answer for this, although good for throughput, it uses dirty reads which can produce inconsistent data. Any suggestion around this?

SQL Agent CmdExec proxy ignored

$
0
0
I am trying to execute a batch file from a SQL Server Agent job cmdexec step. I created a proxy to execute as my domain account (just testing on my machine for now) and assigned that proxy to the job step. Unfortunately, it seems to (sort of) ignore the proxy. I've reduced my test to 1 simple echo command instead of the batch file while I try to figure out what is going wrong. echo %date% %time% %username% The job runs successfully, and this is the output: Executed as user: DEV\tomstaab. Tue 01/12/2016 12:12:49.64 DEVTOMSTAAB$. Process Exit Code 0. The step succeeded. `DEV\tomstaab` is my domain username.
`DEVTOMSTAAB` is my machine name.
Any idea why it would appear to *start* executing as me but then switch to the machine account?

Stored Procedure : Inconsistent times of Execution

$
0
0
Hi Guys I have been facing a scenario where one of the stored procedure is taking more time to execute on certain days than the other. The maximum time it takes is arround 10 minutes and the least is 3 minutes. Stored procedure is part of one of the steps in a sql job. The volume of data and the code remains the same. How would I troubleshoot this case. Thanks Lokesh

SQL Job running long. Need timing for each stored proc running.

$
0
0
Hi, I have a job that just started running long. There is only 1 step which executes a stored procedure. That stored procedure kicks off multiple stored procedures when processing. I'm trying to pinpoint which stored proc is taking so long. What is the best way to determine length of time for each? It runs off hours so I can't execute manually. Thanks!

Sql agent Job

$
0
0
There a SSIS which is set up to run as a job in SQL agent. The jobs executes successfully in visual studio but fails when run as SQL agent job with the follow error messages.

PowerShell versions in SQL Server Agent 2008 R2 - How to upgrade from V1.0 to higher versions

$
0
0
I have question about using PowerShell in SQL Server Agent on SQL Server 2008 R2. * What circumstances would lead to only having PowerShell V1.0 available in SQL Server Agent task steps (even when launching PowerShell.exe from a cmdexec step), and how can I get more advanced versions? Googling has revealed to me that the sqlps "mini-shell" used by the PowerShell steps in SQL Agent typically returns a version of 2, but is very constrained in terms of the cmdlets actually available to it. Therefore, it is common to launch new PowerShell.exe processes to get access to either v2.0 or v3.0 functionality. However, when I schedule steps that launch PowerShell in SQL Agent, the shell appears to be version 1. I am beginning to suspect that this server only HAS version 1 installed (originally, I was mislead by launching the SQLPS shell from within SSMS on my workstation and finding version 3.0 available when I would launch PowerShell.exe within the sqlps console - I am reasonably sure that process was launched from my workstation, not whatever is available server side). Working through this question, I think the answer might be that I need to talk to the sysadmin about updating either the operating system (I think that version number indicates the OS is Windows Server 2003) or install PowerShell V3.0 (or maybe both). Does anyone have any cautionary tales about upgrading PowerShell and SQL Agent? Do we need to uninstall PowerShell V1.0? Will SQL Server Agent be able to pick up the new version of PowerShell without trouble? Addendum - Version info: From a PowerShell script run in SQL Agent, using an operating system task (CMDEXEC), which launched powershell.exe and returned $Host.Version information: Major Minor Build Revision ----- ----- ----- -------- 1 0 0 0 The server version: SELECT @@Version Microsoft SQL Server 2008 R2 (SP2) - 10.50.4000.0 (X64) Jun 28 2012 08:36:30 Copyright (c) Microsoft Corporation Standard Edition (64-bit) on Windows NT 5.2 (Build 3790: Service Pack 2) (Hypervisor)

Can powershell script in sql job step call the next step in the same job

$
0
0
I need to call Step 2 only if criteria is met and it is a certain time of day. Here is the PS script for Step 1 Step 1 - check for files $Checktime = Get-Date $jobName = "Check For Files" $stepName = "Send No Invoices Email" IF ( (Test-Path -Path "\\test\data\AP\*.csv") -eq $true ) { $sqlConnection = new-object System.Data.SqlClient.SqlConnection $sqlConnection.ConnectionString = 'server=test;integrated security=TRUE;database=msdb' $sqlConnection.Open() $sqlCommand = new-object System.Data.SqlClient.SqlCommand $sqlCommand.CommandTimeout = 120 $sqlCommand.Connection = $sqlConnection $sqlCommand.CommandText= "exec dbo.sp_start_job APProcess" $sqlCommand.ExecuteNonQuery() $sqlConnection.Close() } ElseIf ( ($Checktime -ge (Get-Date 8:00) -and $Checktime -lt (Get-Date 9:00) ) ) {$sqlCMD = "EXEC dbo.sp_start_job N'{0}', @step_name = N'{1}'" -f $jobName, $stepName $sqlCMD } Step 2 - Send Specfic email I tried to raise an error and on failure go to step 2, but the first step actually failed and sent incorrect emails. I also tried not assigning the jobname and it failed with syntax error. Can PA initiate a step in the same job?

SQL server agent not starting

$
0
0
Please help : I am trying to restore msdb database backup taken in SQL server 2008 R2 (SP2) to SQL server 2016. Database restore completed successfully however SQL server Agent is not starting. Agent error log: 2018-04-21 07:29:18 - ? [100] Microsoft SQLServerAgent version 13.0.4001.0 (X64 unicode retail build) : Process ID 9264 2018-04-21 07:29:18 - ? [495] The SQL Server Agent startup service account is ********************* 2018-04-21 07:29:18 - ? [393] Waiting for SQL Server to recover database 'msdb'... 2018-04-21 07:29:18 - ? [000] 2018-04-21 07:29:18 - ! [165] ODBC Error: 0, Invalid character value for cast specification [SQLSTATE 22018] 2018-04-21 07:29:18 - ? [101] SQL Server 0 version 13.00.4001 (0 connection limit) 2018-04-21 07:29:18 - ? [102] SQL Server ODBC driver version 14.00.500 2018-04-21 07:29:18 - ? [103] NetLib being used by driver is ****; Local host server is 2018-04-21 07:29:18 - ? [310] 4 processor(s) and 8192 MB RAM detected 2018-04-21 07:29:18 - ? [339] Local computer is ******* running Windows NT 6.2 (9200) 2018-04-21 07:29:18 - ! [000] SQLServerAgent cannot start because the msdb database is read-only 2018-04-21 07:29:18 - ? [000] Configuration option 'Agent XPs' changed from 1 to 0. Run the RECONFIGURE statement to install. [SQLSTATE 01000] (Message 15457) 2018-04-21 07:29:18 - ? [098] SQLServerAgent terminated (normally) Note: msdb database is in read write mode

ssis schdule in ssms

$
0
0

I installed sql server 2017 including SSDT . there is a pckage i created on SSIS and i want to schdule it in SSMS . when i run the job . this is the error i am getting . "Executed as user: NT Service\SQLSERVERAGENT. Microsoft (R) SQL Server Execute Package Utility Version 14.0.2027.2 for 64-bit Copyright (C) 2017 Microsoft. All rights reserved. Started: 11:44:39 PM Error: 2019-08-01 23:44:39.57 Code: 0xC001F02A Source: Package Description: Cannot create a task from XML for task "Execute Process Task", type "Microsoft.ExecuteProcess" due to error 0x80070057 "The parameter is incorrect.". End Error Error: 2019-08-01 23:44:39.57 Code: 0xC0010018 Source: Execute Process Task Description: Failed to load task "Execute Process Task", type "". The contact information for this task is "". End Error Error: 2019-08-01 23:44:39.57 Code: 0xC0010026 Source: Execute Process Task Description: The task has failed to load. The contact information for this task is "". End Error Error: 2019-08-01 23:44:39.57 Code: 0xC0024107 Source: Execute Process Task Description: There were errors during task validation. End Error Error: 2019-08-01 23:44:39.57 Code: 0xC0010025 Source: Package Description: The package cannot execute because it contains tasks that failed to load. End Error DTExec: The package execution returned DTSER_FAILURE (1). Started: 11:44:39 PM Finished: 11:44:39 PM Elapsed: 0.141 seconds. The package execution failed. The step failed." .

I tried everything even by googling. anyone can help?

can't find the object that is running this SQL job

$
0
0

I have a disabled SQL job with no schedule and I can't find the object that is running this job.

It's using a service account and is being executed at the same time every day.

I have searched for the job name everywhere, nothing in any jobs, stored procedures, triggers & functions.

Any help would be greatly appreciated.

(...not sure what the point of disabling a job is, if it can still be run?)


Granting user accounts rights to run only specific SQL agent jobs that run SSIS packages

$
0
0

We have a couple of users that we only would like to run SQL agent jobs that would execute SSIS packages and don't want them to have access to any other thing except to run the jobs. Is there a way I can accomplish this requirement.

Agent Job Error- Sql Linked Server Job error (Error 7350)

$
0
0

I have a scheduled job that is running everyday. The job step is to execute a stored procedure for hourly caching logic for Case load Data.

The job has been successful until yesterday afternoon when it failed with the following errors:

  • Cannot get the column information from OLE DB provider "MSDASQL" for linked server "EDV_TBI". [SQLSTATE 42000] (Error 7350)

  • OLE DB provider "MSDASQL" for linked server "EDV_TBI" returned message "ERROR: TEIID30504 COHORT_PROD_ENT_NICOE: 17008 TEIID11008:TEIID11004Error executing statement(s): [Prepared Values: [] SQL: SELECT DISTINCT g_0."SITE_ID", g_0."DIVISION_DMIS_ID_CODE" FROM "ENT"."CHCS_DIVISION" g_0, (SELECT MAX(g_1."LAST_CHANGED_TIMESTAMP") AS c_0, g_1."DIVISION_DMIS_ID_CODE" AS c_1 FROM "ENT"."CHCS_DIVISION" g_1, "ENT"."CHCS_HOSPITAL_LOCATION" g_2 WHERE g_1."SITE_ID" = g_2."SITE_ID" AND g_1."DIVISION_ID" = g_2."DIVISION_ID" AND g_1."DIVISION_INACTIVE_FLAG" = 'A' AND g_1."DIVISION_NAME" <>". [SQLSTATE 01000] (Error 7412). The step failed.

I am unable to test connections or even run the select statements as above ^ since I am not a mapped login on the remote Oracle server. I am an SA on the local SQL server though.

I have double checked these conditions to make sure that it is not true:

a. Allow Inprocess is not checked for the provider

b. SQL Server service is started as a Local Service

c. The user is a regular user that is part of the Administrator’s group. (either local user or domain user)

d. User Account Control (UAC) is turned off

e. SQL Server Management Studio is opened as the regular user using Windows Authentication

I am suspecting that there may be syntax issues or the query is returning too many rows. But not 100% since I cant run those queries myself. Any other way I can proceed to troubleshoot?

Any recommendations will be helpful.

Job Schedule Management tools and techniques

$
0
0

My company has several SQL servers and a few other servers that run jobs, tasks and processes that affect our data. I would like to start managing these jobs as a big picture/view from above perspective. So, I would be able to schedule maintenance, downtime, special projects, optimize the processes, etc...

Are there any tools out there to help manage scheduled processes across servers? Ideally, I would like to see a ghantt-syle chart similar to the MS Outlook Scheduling Assistant, but I'm very open to other tools and ideas.

Syntax Error While Running Powershell Command Through SQL Agent

$
0
0

Hey Everyone,

I know this will be something simple but hey it's Friday and i can't see the syntax error. Looking for a second set of eyes to help me out here.

I have a SQL Agent job that runs a simple copy command for a bunch of csv file in a folder to another folder every hour. This is the powershell command I need assistance on as it runs fine in powershell but not through the agent

$source_dir='E:\excel_files\MasterFiles'

$dest_dir='E:\excel_files\Upload'



Get-ChildItem -Path $source_dir\ | ForEach-Object {

Copy-Item -Path $_.FullName -Destination "$dest_dir\$($_.BaseName + '_' + (Get-Date).ToString("MMddyyyy_HHmmss") + $_.Extension)"

}


Thanks in advanced!

SQL Job schedule got disabled

$
0
0

Hi,

I am trying to investigate why

all jobs for a particular database were detached from schedule (though jobs were not disabled) but did not trigger having no schedule. (I have attached a screen shot, to identify the Enable check box)

Any thoughts to investigate where shall I look. I could not find any clues from default trace, but have saved default trace into a table

Onwards I am going to setup an Audit. 1665157178483.png


Hint.

any changes in schedule will modify "msdb.dbo.sysschedules" and we can find the last modification but unable to check previous -- we should have some thing in default trace data.

select name, date_created, date_modified from msdb.dbo.sysschedules where CAST(date_modified AS DATE) = '2022-10-06'

Viewing all 80 articles
Browse latest View live