Will Sql Server Agent start job when previous instance is running?
Just as an example, I have a job that is set to run every 5 minutes. The job takes 30 minutes to complete. So sql server agent executes the job at 9:30AM. Will the job run again at 9:35AM even though the previous instance hasn't completed?
In my case, I would like to reproduce what Task Scheduler already has, which is to
not begin a new instance until the previous instance has completed. When the previous instance completes, then 5 minutes later, the job will be run again.
Thanks.
VM
Apparently, it will skip it until the job is completed: http://stackoverflow.com/questions/865042/will-a-sql-server-job-skip-a-scheduled-run-if-it-is-already-running
VM
Similar Messages
-
SQL Server Agent and Jobs and executing @EventData
I have a SQL Server Agent Job and within it a Job Step which states "Execute Report Subscriptions" and a command which has...
exec msdb.dbo.sp_start_job '6FF53AED-855F-43AB-9FB7-064062B8012E' --9:07 subscription
GO
WAITFOR DELAY '00:08';
Now, I find within SQL Server Agent the Job '6FF53AED-855F-43AB-9FB7-064062B8012E' and its step command which is...
exec [ReportServer].dbo.AddEvent @EventType='TimedSubscription', @EventData='ca4e5410-2758-4a1a-9b06-513821e0d962'
How can I drill-down further into the @EventData 'ca4e5410-2758-4a1a-9b06-513821e0d962' to see what it does? I do not see 'ca4e5410-2758-4a1a-9b06-513821e0d962' within SQL Server Agent and Jobs or am I way off base here as to what exactly the @EventData
parameter seems to be?
Thanks for your review and am hopeful for a reply.Hi ITBobbyP,
According to your description, you need to know the what does SQL Server Reporting Services do when fire a subscription, right?
When you create a subscription several things are added to the RS server
A row is placed in the Subscriptions table identifying the name of the report, along with parameter settings, data driven query info and so on to process the subscription
A row is placed in the Schedule and ReportSchedule tables with the timing of the subscription
A SQL Server Agent job is created to control the scheduled execution of the report, and this is stored in the sysjobs and sysjobsteps of the MSDB database.
When the subscription runs several things happen
The SQL Server Agent job fires and puts a row in the Event table in the RS catalog with the settings necessary to process the subscription
The RS server service has a limited number of threads (2 per CPU) that poll the Event table every few seconds looking for subscriptions to process
When it finds an event, it puts a row in the Notifications table and starts processing the subscription
Please refer to the links below to see the details.
http://blogs.msdn.com/b/deanka/archive/2009/01/13/diagnosing-and-troubleshooting-subscriptions.aspx
http://blogs.msdn.com/b/deanka/archive/2010/02/16/troubleshooting-subscriptions-part-ii-using-the-report-services-trace-log-file.aspx
Regards,
Charlie Liao
TechNet Community Support -
I am trying to install TFS 2012 update 4 on single server installation.
I am getting below error:
TF400525: Make sure the SQL Server Reporting Services service for this instance is running.Hi CFSA,
Thanks for your post.
If you want install TFS 2012 Server with Reporting Server, you must ensure the provided Reporting Services is running first.
As Daniel said, please check that in SQL Server Configuration Manager to ensure Reporting Services is installed and running.
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click
HERE to participate the survey. -
I have unique service accounts set up for multiple instances on the same SQL Server 2012.
When step 3 of the inbuilt syspolicy_purge_history job(Erase Phantom System Health Records) runs, it appears to attempt to run against every instance on the server despite being passed the instance path!
The SQLServer's powershell script call:
if ('$(ESCAPE_SQUOTE(INST))' -eq 'MSSQLSERVER') {$a = '\DEFAULT'} ELSE {$a = ''};
(Get-Item SQLSERVER:\SQLPolicy\$(ESCAPE_NONE(SRVR))$a).EraseSystemHealthPhantomRecords()
so with instances SERVER\X this runs as...
(Get-Item SQLSERVER:\SQLPolicy\SERVER\X).EraseSystemHealthPhantomRecords()
SERVER\X's job will run and I will see login failures in the error logs of SERVER\Y and SERVER\Z for the service account set up for instance X.
It seems Microsoft's only 'accepted solution' to this problem is for me to compromise my security by escalating the access of these service accounts?
Has anyone else run into and corrected this failure?Hi Atombath,
When you install multiple instances on one Server, and the SQL Server’s powershell scripts are the same in inbuilt syspolicy_purge_history job steps. However, when you start PowerShell by right clicking
syspolicy_purge_history job, you will find it will point to their own instance. I do a test in my SQL Server 2012,
it will not across instance to collect the error logs. So I recommend you use its original powershell scripts for the syspolicy_purge_history job.
Sometimes, if you run the syspolicy_purge_history job on a clustered instance, the syspolicy_purge_history SQL Server Agent job may fail due to using the computer node name instead of the virtual server name. For more information, see:
http://support.microsoft.com/kb/955726/en-us
In addition, you can use different service account for your multiple SQL Server instances on the same Server. And make sure the accounts that you created get added to the sysadmin fixed server role, the accounts are also set in the three Agent roles (SqlAgentUserRole,
SqlAgentReaderRole, and SqlAgentOperatorRole).
Regards,
Sofiya Li
Sofiya Li
TechNet Community Support -
Hi
We have scheduled job running a console application daily. For some reason on Sunday's only the scheduler says it ran successfully but no email confirmation, table entries and the normal processing occurs.
This happens only on a Sunday and for no explained reason. No problem on the day before or after...
I think this also happened with Daylight Savings adjustment. Has anyone else encountered this?
Any ideas or suggestions
Environment is:
Microsoft SQL Server 2008 R2 (SP2) - 10.50.4000.0 (X64) Jun 28 2012 08:36:30 Copyright (c) Microsoft Corporation Enterprise Edition (64-bit) on Windows NT 6.1 <X64> (Build 7601: Service Pack 1) (Hypervisor)
Thanks in advance
GeorgeMichelle
Thanks for your reply. I was out sick all last week.
I too suspected our network and/or security features or maintenance.
Me and my manager decided to include a text log file which we append certain key points for each iteration when the vb.net console app runs to hopefully determine what is happening sporadically.
I created many errors and scenarios ( DB and network connectivity, unable to send email) and they were caught and appended to the logfile so all I can do is wait to see when/if this occurs.
Sincerely
George
NOTE: DISREGARD THE "Failure Sending mail" exceptions they disabled it for security reasons and it only works for production jobs and special users
DailySerial Feed started at 11:48:34 AM
Attempting DB Connection 11:48:34 AM
DB Connection successful 11:48:34 AM
completed successful 11:48:38 AM Record count: 153 processed
DailySerial Feed started at 11:49:37 AM
Attempting DB Connection 11:49:37 AM
DB Connection successful 11:49:37 AM
completed successful 11:49:42 AM Record count: 0 processed
SendEmail failed 11:49:44 AM - Failure sending mail.
DailySerial Feed started at 4:37:42 PM
Attempting DB Connection 4:37:42 PM
DB Connection successful 4:37:44 PM
completed successfully 4:37:44 PM Record count: 153 processed
SendEmail failed 4:37:45 PM - Failure sending mail.
System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it 10.8.86.78:25
at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress)
at System.Net.Sockets.Socket.InternalConnect(EndPoint remoteEP)
at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Int32 timeout, Exception& exception)
DailySerial Feed started at Monday12:50:29 PM
Attempting DB Connection 12:50:29 PM
DB Connection successful 12:50:29 PM
completed successfully 12:50:30 PM Record count: 153 processed
SendEmail failed Monday12:50:31 PM - Failure sending mail.
System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it 10.8.86.78:25
at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress)
at System.Net.Sockets.Socket.InternalConnect(EndPoint remoteEP)
at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Int32 timeout, Exception& exception)
DailySerial Feed started on Monday, March 23, 2015 - 2:31:40 PM
Attempting DB Connection 2:31:40 PM
Connection failed Monday 2:31:55 PM for: server=ITDEVPTENSDEV\sqlserver2008r2yada;database=ICES;Trusted_Connection=True - A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found
or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)
SendEmail failed Monday 2:31:55 PM - Failure sending mail.
System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it 10.8.86.70:25
at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress)
at System.Net.Sockets.Socket.InternalConnect(EndPoint remoteEP)
at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Int32 timeout, Exception& exception)
Rollback Exception 2:31:55 PM - unable to OPEN the DB ConnectionA network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct
and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified) - - Connection established
SendEmail failed Monday 2:31:55 PM - Failure sending mail.
System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it 10.8.86.70:25
at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress)
at System.Net.Sockets.Socket.InternalConnect(EndPoint remoteEP)
at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Int32 timeout, Exception& exception)
DailySerial Feed started on Monday, March 23, 2015 - 2:36:38 PM
Attempting DB Connection 2:36:38 PM
DB Connection successful 2:36:38 PM
DailySerial feed completed 2:36:38 PM Record count: 0 processed
SendEmail failed Monday 2:36:38 PM - Failure sending mail.
System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it 10.8.86.70:25
at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress)
at System.Net.Sockets.Socket.InternalConnect(EndPoint remoteEP)
at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Int32 timeout, Exception& exception)
DailySerial Feed started on Monday, March 23, 2015 - 2:37:03 PM
Attempting DB Connection 2:37:03 PM
DB Connection successful 2:37:03 PM
DailySerial feed completed 2:37:03 PM Record count: 153 processed
SendEmail failed Monday 2:37:03 PM - Failure sending mail.
System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it 10.8.86.70:25
at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress)
at System.Net.Sockets.Socket.InternalConnect(EndPoint remoteEP)
at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Int32 timeout, Exception& exception)
Imports System.IO
Imports System.Net
Imports System.Text
Imports System.Data.SqlClient
Imports System.Data.Common
Public Module DailySerialFeed
Dim attempts As Integer = 0
Dim sb As New StringBuilder
Dim myconnection As New SqlConnection
Dim m_SqlConnStr As String = My.Settings.SqlConnStr
Dim strCardAFCExportBatchIDGuid As String
Dim LogMessage As String
Dim TotalExtracted As Integer
Public sSource As String = "DailySerialFeed"
Public Slog As String = "Application"
Public sEvent As String = ""
Public ErrText As String
Public sMachine As String = "."
Dim mySqlTransaction As SqlTransaction
Dim time As DateTime = DateTime.Now
Dim format As String = "MMM ddd d HH:mm yyyy"
Dim LogFile As StreamWriter ' SFTPData\AFC\DailySerialFeedLog.TXT
Dim ExceptionString As String
Public Sub Main()
Try
LogFile = New StreamWriter(My.Settings.LogFile, FileMode.Append) ' append to file
LogFile.WriteLine("") '(Environment.NewLine)
LogFile.WriteLine("DailySerial Feed started on " & Now.ToString("D") & " - " & Now.ToLongTimeString)
strCardAFCExportBatchIDGuid = System.Guid.NewGuid().ToString
LogFile.WriteLine(" Attempting DB Connection " & Now.ToLongTimeString)
OpenDBConnection()
LogFile.WriteLine(" DB Connection successful " & Now.ToLongTimeString)
mySqlTransaction = myconnection.BeginTransaction("OuterTransaction")
'PadSerialNumbers() Lewycky 7/19/13 Zero digit padding for 8 or 9 digital serial numbers Disabled
'RemoveZeroSerial() ' Lewycky 11/3/11 remove zero serial numbers from being sent to AFC now in FlagSerialforExtract module
FlagSerialforExtract()
ExtractFlaggedSerialFile()
mySqlTransaction.Commit()
CloseDBConnection()
StageforFTPAndArchive()
sb.AppendLine(" " & "DailySerial Feed completed. Record count: " & TotalExtracted & " processed")
LogFile.WriteLine(" DailySerial feed completed " & Now.ToLongTimeString & " Record count: " & TotalExtracted & " processed")
Catch ex As Exception
If Not mySqlTransaction Is Nothing Then
LogFile.WriteLine(" Rollback Exception " & Now.ToLongTimeString & " - " & ex.Message)
mySqlTransaction.Rollback("OuterTransaction")
End If
sb.AppendLine(" " & "Problem encountered with DailySerialFeed extract :" & ex.Message & " - " & ErrText)
LogFile.WriteLine(" Rollback Exception " & Now.ToLongTimeString & " - " & ex.Message & " - " & " - " & ErrText)
Finally
SendEmail(RTrim(sb.ToString))
' if dbconnection is still open during exception/error force it closed
If myconnection.State = ConnectionState.Open Then
LogFile.WriteLine(" Closing DB Connection(2) " & Now.ToLongTimeString & " - ")
CloseDBConnection()
End If
LogFile.Close()
End Try
End Sub
Public Sub OpenDBConnection()
myconnection = New SqlConnection(m_SqlConnStr)
Try
myconnection.Open()
Catch ex As Exception
Dim strErr As String = ex.Message
LogFile.WriteLine(" Connection failed " & Now.ToString("dddd ") & Now.ToLongTimeString & " for: " & My.Settings.SqlConnStr & " - " & strErr)
SendEmail(strErr)
Throw New System.Exception("unable to OPEN the DB Connection" & strErr)
Finally
ErrText = "Connection established "
'sb.AppendLine("Connection established ")
End Try
End Sub
Public Sub FlagSerialforExtract()
' Update the batch of records in CardAFCExport table with the GUID related to that batch created earlier
' Now included in the same Commmand - removal of any zero digit serial numbers previously in another module
Dim myCommand As New SqlCommand
Try
' lewycky pull serial numbers prior to midnite 1 day lag
' lewycky use the GUID created in the Main() for updating in dbo.CardAFCExport indetifying qualifying serial
' numbers for this daily batch to ultimately be sent to AFC and to receive back detailed metrocard data
myCommand = New SqlCommand("DELETE from CardAFCExport where CAST(CardSerialNumber as bigint)= 0;Update CardAFCExport Set CardAFCExportBatchID = '" & strCardAFCExportBatchIDGuid & "' where
CardAFCExportBatchID is null and CreatedDate < DATEADD(dd,0,datediff(dd,0,getdate()))", myconnection, mySqlTransaction)
myCommand.ExecuteNonQuery()
Catch ex As Exception
Dim strErr As String = ex.Message
ErrText = "unable to update the batch with its GUID " & strErr & " "
sb.AppendLine("unable to update the batch with its GUID." & " ")
sb.AppendLine("Error Message : " & ex.Message)
LogFile.WriteLine(" FlagSerialforExtract failed " & Now.ToLongTimeString & " - " & strErr)
Throw New System.Exception(strErr)
Finally
ErrText = "Serial numbers flagged with GUID successfully "
'sb.AppendLine("Serial numbers flagged with GUID successfully ")
End Try
End Sub
'Public Sub PadSerialNumbers() 7/19/13 Lewycky Disabled per Serial numbers becoming duplicated if the enter with and without zeros
' Dim myCommand As New SqlCommand
' Try
' myCommand = New SqlCommand("update CardAFCExport set CardSerialNumber = '0' + CardSerialNumber where CardSerialNumber in (SELECT CardSerialNumber FROM CardAFCExport where LEN(cardserialnumber) = 9 )",
myconnection, mySqlTransaction)
' myCommand.ExecuteNonQuery()
' myCommand = New SqlCommand("update CardAFCExport set CardSerialNumber = '00' + CardSerialNumber where CardSerialNumber in (SELECT CardSerialNumber FROM CardAFCExport where LEN(cardserialnumber) = 8 )",
myconnection, mySqlTransaction)
' myCommand.ExecuteNonQuery()
' Catch ex As Exception
' Dim strErr As String = ex.Message
' ErrText = "unable to pad serial serial numbers" & strErr
' sb.AppendLine("unable to pad serial serial numbers" & " ")
' sb.AppendLine("Error Message : " & ex.Message & " ")
' SendEmail(strErr)
' Throw New System.Exception(strErr)
' Finally
' ErrText = "Serial numbers padded successfully "
' sb.AppendLine("Serial numbers padded successfully ")
' End Try
'End Sub
'Public Sub RemoveZeroSerial()
' now in the FlagSerialforExtract module
' ' Zero Serial number deletion still needed ( 8 & 9 digit ) otherwise 999 records will be generated on ICES when AFC returns file
' Dim myCommand As New SqlCommand
' Try
' myCommand = New SqlCommand("DELETE from CardAFCExport where CAST(CardSerialNumber as bigint)= 0", myconnection, mySqlTransaction)
' ' myCommand = New SqlCommand("delete from CardAFCExport where CardSerialNumber = '0000000000' ", myconnection, mySqlTransaction)
' myCommand.ExecuteNonQuery()
' Catch ex As Exception
' Dim strErr As String = ex.Message
' ErrText = "unable to remove Zero Serial Numbers" & strErr
' sb.AppendLine("unable to remove Zero Serial Numbers.")
' sb.AppendLine("Error Message : " & ex.Message)
' SendEmail(strErr)
' Throw New System.Exception(strErr)
' Finally
' ErrText = "Zero serial numbers removed "
' sb.AppendLine("Zero serial numbers removed successfully ")
' End Try
'End Sub
Public Sub ExtractFlaggedSerialFile()
' extract metrocard serial number feed in ascending order and w/o dupes
Dim column1 As String
Dim TotalRecords As Integer = 0
Dim myCommand As New SqlCommand
Dim objStreamWriter As StreamWriter
Try
' 7/19/13 - Lewycky modification to remove duplicates and omit the same serial number entered as a 8 or 9 digit number instead of the
' required 10 digit for AFC w/o extra DML updates due to Serialnumber being a Unique value per batch
myCommand = New SqlCommand("SELECT DISTINCT RIGHT('00' + Cardserialnumber,10) Cardserialnumber FROM CardAFCExport where CardAFCExportBatchID = '" & strCardAFCExportBatchIDGuid & "' order by
CardSerialNumber", myconnection, mySqlTransaction)
' myCommand = New SqlCommand("SELECT distinct CardSerialNumber FROM CardAFCExport where CardAFCExportBatchID = '" & strCardAFCExportBatchIDGuid & "' order by CardSerialNumber", myconnection,
mySqlTransaction)
myCommand.CommandType = CommandType.Text
objStreamWriter = File.CreateText(My.Settings.AFCExportInterimFile.ToString)
Dim myreader As SqlDataReader = myCommand.ExecuteReader
While myreader.Read
column1 = myreader.Item("CardSerialNumber").ToString
objStreamWriter.WriteLine(column1)
TotalExtracted = TotalExtracted + 1
End While
myreader.Close()
objStreamWriter.Close()
' Extract file is now created
myCommand = New SqlCommand("INSERT INTO CardAFCExportBatch (CardAFCExportBatchID, TotalRecords, ExportedDate, CreatedDate, CreatedBy) values ( '" & strCardAFCExportBatchIDGuid & "', " +
TotalExtracted.ToString + ", GETDATE(), GETDATE(), '00000000-0000-0000-0000-000000000000')", myconnection, mySqlTransaction)
myCommand.ExecuteNonQuery()
Catch ex As Exception
Dim strErr As String = ex.Message
ErrText = "unable to create extract from CardAFCExport last input record " & TotalRecords & "' '" & strErr
LogFile.WriteLine(" ExtractFlaggedSerialFile failed " & Now.ToLongTimeString & " - " & ErrText)
LogMessage = ErrText
sb.AppendLine(ErrText)
sb.AppendLine("Error Message : " & ex.Message)
SendEmail(LogMessage)
Throw New System.Exception("unable to create extract from CardAFCExport last record " & TotalRecords)
Finally
ErrText = "Batch Info updated & Extract created. Rec count: " & TotalExtracted
End Try
End Sub
Public Sub StageforFTPAndArchive()
'KD - Getting file ready for AFC ftp. Also archive the file with date time stamp.
Try
Dim strFileName As String = Path.GetFileNameWithoutExtension(My.Settings.AFCExportInterimFile)
Dim strDirectory As String = Path.GetDirectoryName(My.Settings.AFCExportInterimFile)
Dim strTimeStamp As String = Now.ToString("MMddyyyyhhmmss")
Dim strExtension As String = Path.GetExtension(My.Settings.AFCExportInterimFile)
'KD : copy AFCSWIPE.TXT file to outgoing folder
System.IO.File.Copy(My.Settings.AFCExportInterimFile, My.Settings.AFCExportFile.ToString, True)
'KD : make yyyyMMDD_hhmmss_ICE_SWP.TXT file to outgoing folder for MCO (Randy Steiner)
System.IO.File.Copy(My.Settings.AFCExportInterimFile, My.Settings.AFCExportFilePath + Now.ToString("yyyyMMdd_hhmmss") + "_ICE_SWP.TXT", True)
'KD : Archive file in archieve folder with date time stamp
System.IO.File.Move(My.Settings.AFCExportInterimFile, My.Settings.AFCExportArchivePath + strFileName + "_" + strTimeStamp + strExtension)
Catch ex As Exception
sb.AppendLine("Error occurred in StageforFTPAndArchive." + Chr(13) + Chr(10))
sb.AppendLine("Error Message : " & ex.Message + Chr(13) + Chr(10))
LogFile.WriteLine(" StageforFTPAndArchive failed " & Now.ToLongTimeString & " - " & ex.Message)
Throw ex
End Try
End Sub
Sub SendEmail(ByVal msg As String)
' Dim myWebRequest As WebRequest
' Dim myStreamReader As StreamReader
Dim strSubject, strBody As String
Dim myMailMessage As Mail.MailMessage
Dim mySmtpClient As Mail.SmtpClient
strBody = msg
' Get subject from settings and replace placeholder with current date
strSubject = My.Settings.EmailSubject
strSubject = strSubject.Replace("<date>", FormatDateTime(Now(), DateFormat.ShortDate))
Try
myMailMessage = New Mail.MailMessage(My.Settings.EmailFrom, My.Settings.EmailTo, strSubject, strBody)
If My.Settings.EmailCC <> "" Then myMailMessage.CC.Add(My.Settings.EmailCC)
myMailMessage.IsBodyHtml = My.Settings.EmailHtml
' Send email
mySmtpClient = New Mail.SmtpClient()
mySmtpClient.Host = My.Settings.SmtpServer()
mySmtpClient.Send(myMailMessage)
Catch ex As Exception
Console.Write("could not send Mail-" & ex.Message)
'ExceptionString = "Exception type " & ex.GetType.ToString & Environment.NewLine & "Exception message: " & ex.Message + Environment.NewLine
'& "Stack trace: " + ex.StackTrace + Environment.NewLine;
'LogFile.WriteLine(ExceptionString)
'LogFile.WriteLine(" SendEmail failed " & Now.ToLongTimeString & " - " & ex.Message.ToString & ex.InnerException.ToString)
' w.o stack trace ?
LogFile.WriteLine(" SendEmail failed " & Now.ToString("dddd ") & Now.ToLongTimeString & " - " & ex.Message.ToString & Environment.NewLine & (DirectCast(ex.InnerException,
System.Exception).InnerException.ToString))
End Try
End Sub
Public Sub CloseDBConnection()
Try
myconnection.Close()
Catch ex As Exception
Dim strErr As String = ex.Message
LogFile.WriteLine(" CloseDBConnection failed " & Now.ToString("dddd ") & Now.ToLongTimeString & " for: " & My.Settings.SqlConnStr & " - " & strErr)
Throw New System.Exception("unable to CLOSE the DB Connection" & strErr)
Finally
ErrText = " DB Conn closed & Serial Feed completed normally "
End Try
End Sub
End Module -
Schedule SSIS packages as job in SQL Server Agent errors
Hi, I am using SQL Server 2008 R2 and created few SSIS packages and schedule them using SQL Server Agent and every time I try to schedule packages via SQL Server Agent my jobs keep failing. I am using domain/ione as the owner and when I invoke the job on
ServerA let's say and the job gets executed by domain/ServerA$ and fails as it does not have enough privileges. How do I fix this issue firstly without the proxy and why is the job being executed by domain/ServerA$ when the owner & user who invokes
it is domain/ione?
Thanks in advance............
IoneHi Ione,
The owner of any SQL jobs should be SA or any other non-expiring account
If you do not want the proxy used, then add the needed priveleges.
The owner of the job is one, the SSIS step gets executed by the account the Agent is running under.
Arthur
MyBlog
Twitter -
Starting SQL Server Agent service
I have a brand new 64-bit laptop and have installed both SQL Server 2014 and SQL Server 2012sp1, but neither instance is able to start its SQL Sever Agent Service. The error is 1053: 'The service did not respond to the start or control request
in a timely fashion'. Googling that message does not seem to give helpful step by step solutions. Please help.
Dave Juergens
[email protected]
Dave Juergenscould you tell us your sql server edition - if it is EXPRESS edition - it does not comes with SQL Server agent. you will sql server agent service in configuration manager but it does not start because the feature is not available.
you can find the sql edition using. select @@version
and post the output here
if it is not Express edition, could you please check the error log or event viewer and if there is more detailed information on the error.
Hope it Helps!! -
Sql server agent jobs deleting problem
hi team,
while i am trying to deleting in the sql server agent disabled jobs through sql query, that time i am getting below error.
query is:
delete from dbo.sysjobs
where version_number=5
error message:
Msg 547, Level 16, State 0, Line 1
The DELETE statement conflicted with the REFERENCE constraint "FK__sysjobsch__job_i__32E0915F". The conflict occurred in database "msdb", table "dbo.sysjobschedules", column 'job_id'.
The statement has been terminated.Hi,
You can delete multiple jobs
by using SQL Server Management Studio:
1.In Object Explorer, connect to an instance of the SQL Server Database Engine, and then expand that instance.
2.Expand SQL Server Agent.
3.Right-click Job Activity Monitor, and click View Job Activity.
4.In the Job Activity Monitor, select the jobs you want to delete, right-click your selection, and choose Delete jobs.
For your information:
Delete One or More Jobs
http://technet.microsoft.com/en-us/library/ms187850.aspx
Thanks.
Tracy Cai
TechNet Community Support -
Report Schedule - SQL Server Agent
Hi,
We have few SSRS reports which has to run daily after the data is loaded in the database.
I scheduled the reports on timely based and got the Job Id's using SQL server agent and using SP_START_JOBs stored procedure to run.
But the problem is it is creating multiple files one for time and one for SP_START_JOBS procedure.
Any idea how to avoid this?
I really appreciate any help.
Thanks,
SarahIf you're going to schedule your SSRS jobs using the agent, don't schedule them in SSRS using subscriptions as well...
Don't forget to mark helpful posts, and answers. It helps others to find relevant posts to the same question. -
LabVIEW 8.6.1 DSC Module and SQL Server Agent
I had the following system constellation:
- LabVIEW Professional Dev System 8.6.1 installed (complete)
- SQL Server 2005 Express
Since Microsoft's SQL Server 2005 is no longer distributed, I had to install SQL Server 2008 Express on my system, too.
Everything is working fine, but after installing the 2008 Express version the SQL Server Agent appears in the '2008 instance!
This is quite good, but normaly the Express editions doesn't contain the Agent...?!
Since LV8.5 (?) the DSC module uses Microsoft SQL Server Express, right? (--> This is very good, but the documentation of the DSC module is more than bad.!!)
Is there any context between SQL 2008 Express <--> LV DSC??Hi _avr_,
There's no documentation about LV DSC
supporting SQL Express 2008 because it's not supported. It may work if
you were to detach the database and reattach it, but it's something we
have not tested.
You are writing, that SQL Server 2005 Express is no longer distributed, however this is a Software which is a part of Installation Pack of a DSC Module. So if you have the DVD for LabVIEW with DSC Module you could install it without any problem. For DSC Module 8.6 we included the SQL Server 2005 Express SP1 on the DVD.
I do not really now why in your case the Agent is appering. You have right, the SQL Server 2008 Express does not contain any Agent.I do not have any explenation for it.
NI supports only DSC with SQL Server 2005 Express. The DSC Module 2009 is also working with SQL Server 2005 Express SP1. For Windows 7 SQL 2005 SP3 is recomended.
I would suggest you to deinstall the SQL Server 2008 Express.
Best regards,
ENIA
NI Germany -
Management Studio Fails when added Integration Services step to SQL Server Agent Job
Hi,
I have two new servers I've setup with Windows Server 2012, SQL Server 2012 SP1, Visual Studio 2012 SP4. I've previously been on SQL 2008 and VS 2008 so this is new to me.
I am finding SSMS is throwing an exception on both machines when i do the following:
1. Go to SQL Server Agent | Jobs
2. Create a new Job.
3. Select Steps and click New Step
4. Change the job type to SQL Server Integration Services Package.
Following error occurs:
TITLE: Microsoft SQL Server Management Studio
The type initializer for '<Module>' threw an exception. (SqlManagerUI)
ADDITIONAL INFORMATION:
The C++ module failed to load.
(DTEParseMgd)
Index was outside the bounds of the array. (DTEParseMgd)
I also find if I take an existing job with SSIS package steps and attempt to edit those steps the same message appears. This issue happens on both my servers as they have been configured almost identically. This doesn't occur when selecting any other job
type.
I've also tried installing cumulative update 8 in a hope that this may fix it but with no success.
As my entire environment is based around SQL Agents running SSIS i'm a little bit concerned, especially since I have some tight deadlines getting these servers running.
I have found nothing relating to this issue. Any help greatly appreciated.
Simon
Below is the detailed error message:
===================================
The type initializer for '<Module>' threw an exception. (SqlManagerUI)
Program Location:
at Microsoft.SqlServer.Management.SqlManagerUI.DTSJobSubSystemDefinition.Microsoft.SqlServer.Management.SqlManagerUI.IJobStepPropertiesControl.Load(JobStepData data)
at Microsoft.SqlServer.Management.SqlManagerUI.JobStepProperties.UpdateJobStep()
at Microsoft.SqlServer.Management.SqlManagerUI.JobStepProperties.typeList_SelectedIndexChanged(Object sender, EventArgs e)
at System.Windows.Forms.ComboBox.OnSelectedIndexChanged(EventArgs e)
at System.Windows.Forms.ComboBox.set_SelectedIndex(Int32 value)
at System.Windows.Forms.ComboBox.set_SelectedItem(Object value)
at Microsoft.SqlServer.Management.SqlManagerUI.JobStepProperties.InitializeStepCombo()
at Microsoft.SqlServer.Management.SqlManagerUI.JobStepProperties.InitializeData()
at Microsoft.SqlServer.Management.SqlManagerUI.JobStepProperties.OnInitialization()
at Microsoft.SqlServer.Management.SqlMgmt.ViewSwitcherControlsManager.SetView(Int32 index, TreeNode node)
at Microsoft.SqlServer.Management.SqlMgmt.ViewSwitcherControlsManager.SelectCurrentNode()
at Microsoft.SqlServer.Management.SqlMgmt.ViewSwitcherControlsManager.InitializeUI(ViewSwitcherTreeView treeView, ISqlControlCollection viewsHolder, Panel rightPane)
at Microsoft.SqlServer.Management.SqlMgmt.LaunchForm.InitializeForm(XmlDocument doc, IServiceProvider provider, ISqlControlCollection control)
at Microsoft.SqlServer.Management.SqlMgmt.LaunchForm..ctor(ISqlControlCollection control, IServiceProvider provider)
at Microsoft.SqlServer.Management.SqlManagerUI.JobSteps.editJobStep_Click(Object sender, EventArgs e)
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.RunDialog(Form form)
at System.Windows.Forms.Form.ShowDialog(IWin32Window owner)
at System.Windows.Forms.Form.ShowDialog()
at Microsoft.SqlServer.Management.SqlMgmt.RunningFormsTable.RunningFormsTableImpl.ThreadStarter.StartThread()
===================================
The C++ module failed to load.
(DTEParseMgd)
Program Location:
at <CrtImplementationDetails>.LanguageSupport.Initialize(LanguageSupport* )
at .cctor()
===================================
Index was outside the bounds of the array. (DTEParseMgd)
Program Location:
at _getFiberPtrId()Hi,
I hadn't installed CU3 however as a test i tried installing CU4 and this didn't help. Since my first emails i have more issues that have brought a complete hault to the upgrade project.
If i double click on a package to run it manually I basically get the same issue. This means i have no way of running any packages except throught VS.
I've also found that regardless of the order of the software installs it still fails. It's related to SP1 of SQL and SP4 of VS.
I'm on Server 2012. When install in the following order SQL 2012, SQL SP1, VS2012, BIDS, VS SP4 i have no problem until VS SP4 is installed. If i install VS SP4 then BIDS it also fails at the last step. If i install all the VS and BIDS software first, then
SQL then SQL SP1 it fails at the SQL SP1 step.
This means i could actually install everything and either ignore the SQL SP1 or the VS SP4 and i'd be fine however this is not really a solution as i will never be able to patch the software and once live this is very dangerous.
I am still surprised there is no obvious solution to this. I'm only installing MS software on a fresh box and only installing 5 pieces of software (including the SPs). I would have though if this was an issue others would have come across it too.
Has anyone else installed all these components and got them working on the same OS. I believe early on in my testing i installed these in Windows Server 2008 and didn't have the issue.
Regards.
Simon. -
HOw to avoid DeadLocks when you schedule a Sql Server Agent Job and calling SSIS packages
Hi All,
I have scheduled 2 packages in in Sql Server Agent jobs .
First job which is having Package 1 executing at 11 AM and where I am inserting the data in the table.
Second job which is having Package 2 executing at 12 AM and where I am updating the data in the table based on the first job inserted records.
When I am executing my first job it taking more time and executing till 12 AM and from 12 AM my job 2 also starting ,so getting deadlocks conflicts because inserting happening from job1 and updating happening from Job 2.
How to avoid deadlocks and fix the issue.
Please Suggest .
Thanks & Regards,
AnandHi Anand,
Here is another solution, you can set the Job 2 not to run based on a schedule, and create another SQL Server Agent Job which starts at 12 AM and run with a specified time interval to execute a SQL statement in which you do the following steps:
1. Get the status information of Job 1 using the statement:
DECLARE @i int;
EXEC @i = msdb.dbo.sp_help_job @job_name = ‘Job Name'
2. If the value of @i is 1 which means the status of job 1 is success and current time is, then start the job 2. So, the statement is as follows:
IF @I = 1
EXEC msdb.dbo.sp_start_job @job_name= ‘Job Name’
Regards,
Mike Yin
TechNet Community Support -
SSIS Package Fails when Scheduled as a SQL Server Agent Job
I have an SSIS package that runs without any problems when executed through BIDS.
However, when I schedule the SSIS as an Agent job, it fails completely or part way through. When it partially runs, the part that it is failing on is a Script Task that moves the source data file to an archive folder (on the same server).
I have tried using my domain account as the owner of the job, then the job fails straight off and I get an error:
Unable to determine if the owner (Domain\MyID) of job JobName has server access (reason: Could not obtain information about Windows NT group/user 'Domain\MyID'
If I change the owner to the 'sa' account , then the job partially runs, but then fails because 'sa' is a SQL account and does not have access to the filesystem.
I have managed to get it to work by using the SQL2008_Local account and granting modify permissions to the affected folders.
My question is - what is the advised way of doing this?
Thanks
GaryHi Garyv.King,
When you see a SSIS package fails running in a SQL Agent job, you need to first consider the following conditions:
1. The user account that is used to run the package under SQL Server Agent differs from the original package author.
2. The user account does not have the required permissions to make connections or to access resources outside the SSIS package.
For more detailed information about the issue, please following this KB article:
An SSIS package does not run when you call the SSIS package from a SQL Server Agent job step
http://support.microsoft.com/kb/918760
You can check SQL Server Agent’s activity logs, Windows Event logs and SSIS logs to get more clues. Also the tool Process Monitor is helpful to track the cause of registry or file access related issues.
The following 4 issues are common encountered in the SSIS forum.
1. The package's Protection Level is set to EncryptSensitiveWithUserKey but your SQL Server Agent service account is different from the SSIS package creator.
2. Data source connection issue.
3. File or registry access permission issue.
4. No 64-bit driver issue.
For more information about it, please see:
How do I troubleshoot SSIS packages failed execution in a SQL Agent job:
http://social.technet.microsoft.com/Forums/en-US/sqlintegrationservices/thread/e13c137c-1535-4475-8c2f-c7e6e7d125fc
Thanks,
Eileen -
Excel Import Fails in SQL Server Agent Job but not when executed in BIDS
We have a SQL Server agent job that has ran successfully for the past 6 months. It started failing about a week ago. I don't believe anyone installed anything on the server. The proxy account used to run the job is an admin on the server.
I've tried everything I can think of or that I found on searches. I even changed the connection manager from an Excel source to using an Microsoft office 12.0 Access Database Engine OLEDB connection and it still runs in BIDs and not as an agent job.
I also setup my LANID as a proxy account to see if the job would run (checking security) -- and it fails with the same error. I also made sure the path is
\\server\share rather than a drive letter. Any ideas?
The package is executed in 32 bit mode. The package still runs fine in BIDS (where BIDs is opened on the server) but fails in the SQL Agent job with:
Executed as user: xxxxxx\xxxxxx. Microsoft (R) SQL Server Execute Package Utility Version 11.0.2100.60 for 32-bit Copyright (C) Microsoft Corporation. All rights reserved. Started: 9:00:00 AM Error: 2014-12-01 09:00:02.46
Code: 0xC0202009 Source: xxxxxx Connection manager "Excel Connection Manager" Description: SSIS Error Code DTS_E_OLEDBERROR. An OLE DB error has occurred. Error code: 0x80004005. An OLE
DB record is available. Source: "Microsoft Access Database Engine" Hresult: 0x80004005 Description: "External table is not in the expected format.". End Error Error: 2014-12-01 09:00:02.65
Code: 0xC020801C Source: Load File to Staging Excel Source [43] Description: SSIS Error Code DTS_E_CANNOTACQUIRECONNECTIONFROMCONNECTIONMANAGER. The AcquireConnection method call to the connection manager
"Excel Connection Manager" failed with error code 0xC0202009. There may be error messages posted before this with more information on why the AcquireConnection method call failed. End Error Error: 2014-12-01 09:00:02.77
Code: 0xC0047017 Source: Load File to Staging SSIS.Pipeline Description: Excel Source failed validation and returned error code 0xC020801C. End Error Error: 2014-12-01 09:00:02.90
Code: 0xC004700C Source: Load File to Staging SSIS.Pipeline Description: One or more component failed validation. End Error Error: 2014-12-01 09:00:03.02 Code: 0xC0024107
Source: Load File to Staging Description: There were errors during task validation. End Error DTExec: The package execution returned DTSER_FAILURE (1). Started: 9:00:00 AM Finished: 9:00:03 AM
Elapsed: 2.761 seconds. The package execution failed. The step failed.I logged on to the server with the account that the SQL Agent runs under and ran the following from a command
line to execute the package:
"D:\Program Files (x86)\Microsoft SQL Server\110\DTS\Binn\DTEXEC.exe" /FILE
"\"K:\SSIS\xxxxxx\xxxxx.dtsx\"" /CHECKPOINTING OFF
/REPORTING EWCDI /X86
I wanted to see if it was a security issue with the agent account account - but
this ran fine.
I then updated the SQL Agent job to use an operating system command instead
of a SSIS package on the job step. This fails...
The issue is definately with the SQL Server Agent -
I've seen some conflicting things in terms of dynamic Excel commands running in a SSISDB Package and a scheduled SQL Server Agent Job...things like that it's not supported...that it won't work...etc...
It's a pretty simple script...to open up a .xlsx file and save it as a .xls file. I am trying to be proactive here and the reason I did it this way is because I could not source the .xlsx file and then I couldn't use OLE DB sourcing because I think the .xlsx
file wants you to use Microsoft.ACE.OLEDB.12.0 and that entails installing the 64-bit Microsoft Access Database Engine and I cannot do that because our network version of Microsoft Office 2010 is 32-bit and in order to install the 64-bit Microsoft Access Database
Engine 2010 it's prompting me to uninstall Microsoft Office 2010 and that is not possible.
Ugh!
So I'm hoping that I can promote and deploy this current SSIS Package to Production and create a SQL Server Agent Job that will successfully run this and its dynamic Excel commands.
Do you know of any hurdles with this? Any anomalies...struggles...
Thanks for your review and am hopeful for a reply.
Here's the C# Script...which works perfectly client side...
string StrFileName = (Dts.Variables["User::FileName"].Value.ToString());
StrFileName = Path.GetFileNameWithoutExtension(StrFileName);
string StringSourceFile = (Dts.Variables["User::FilePath"].Value.ToString()) + StrFileName + ".xlsx";
string StringDestinationFile = (Dts.Variables["User::FilePath"].Value.ToString()) + StrFileName + ".xls";
// This initiates the Excel Application
Microsoft.Office.Interop.Excel.Application excelApplication = new Microsoft.Office.Interop.Excel.Application();
// This Opens the Source .xlsx File from Emdeon ePaySmart
Workbook workbook = excelApplication.Workbooks.Open(StringSourceFile, XlUpdateLinks.xlUpdateLinksNever, true, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
// This will Save the Source .xlsx Emdeon ePaySmart File as a .xls File...note xlFileFormat.xlExcel5
workbook.SaveAs(StringDestinationFile, XlFileFormat.xlExcel8, Type.Missing, Type.Missing, Type.Missing, Type.Missing, XlSaveAsAccessMode.xlExclusive, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
// This will Close the Source
workbook.Close(false, Type.Missing, Type.Missing);
// This shuts down the Excel Application
excelApplication.Quit();This should work if you use a proxy to run this package in the Agent; see:
http://www.mssqltips.com/sqlservertip/2163/running-a-ssis-package-from-sql-server-agent-using-a-proxy-account/
Arthur
MyBlog
Twitter
Maybe you are looking for
-
Is there any way to combine multiple Apple IDs for the same individual?
I have two Apple IDs, one of which has a .mac email address. Both have the same name and physical address. With the new iTunes and the coming iCloud, it would be convenient to combine the two for purchase history and access, app updates, etc. How can
-
Hi, i'm trying to update my iphone but this is the msg i'm getting, can you please help me. thank you. "the iphone ''C & M '' could not be restored. An unknown error occurred (3194)"
-
DI: How to set a category for userdefined fields?
Hi, I've created some userdefinded fields using DI API and now I would like to assign them to a specific category. By default they are in category "General". How to do this programmatically? Thanks, Ronny
-
Could it be that Mac OS 10.9.4 is preventing me from Beta testing Yosemite ?
Try as I may, I have tried twice ( failure of first attempt prompted a second try,) to download and activate the Yosemite Beta Test only to find that both were on the Apple Store site and shown as "Downloaded" but obviously not "Installed". So far, a
-
Hi, I am new to Oracle and I want to imporve sql query skills. Are there any exercice on net avalible for learning how to write complex sql statements. Please advice Regards, Riyadh