sql-agent-job

SQL Agent Job: Determine how long it has been running

邮差的信 提交于 2019-12-09 10:11:51
问题 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 while, a job might 'hang'. This doesn't produce a failure (since the job hasn't stopped yet). When this happens, the job can be manually stopped and works fine the next time it runs. It's designed to pick back up where it left off. What's the most

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

SSIS package fails in sql server agent, but not in visual studio. ODBC Connection

馋奶兔 提交于 2019-12-08 07:26:59
问题 I have an SSIS package that runs fine in visual studio 2010, but as a job it sql server it fails when connecting to an ODBC database. The project encrypts sensitive data with a password. This is because the proxy server isn't my account. It also happens to be the user that connects to the ODBC with a connection string. The job connects to a couple non-ODBC databases successfully before failing at the ODBC connection. The project is set up to run in 32-bit mode, but strangely enough when I set

SSIS package fails in sql server agent, but not in visual studio. ODBC Connection

僤鯓⒐⒋嵵緔 提交于 2019-12-07 15:26:27
I have an SSIS package that runs fine in visual studio 2010, but as a job it sql server it fails when connecting to an ODBC database. The project encrypts sensitive data with a password. This is because the proxy server isn't my account. It also happens to be the user that connects to the ODBC with a connection string. The job connects to a couple non-ODBC databases successfully before failing at the ODBC connection. The project is set up to run in 32-bit mode, but strangely enough when I set it to 64-bit it'll fail at the ODBC connection. All the servers are set to run with the current user

SSIS 2012 SQL Agent Job ConnectionString vs InitialCatalog

梦想与她 提交于 2019-12-05 16:14:05
I was not able to find a resource discussing this from the SQL Agent and SSIS Catalog. I'm getting behavior that was unexpected when running a package from SQL Agent. I believe that the issue is that I specified a different InitialCatalog property in the sql agent configuration than I used in my connection string environment variable. Here you can see my connection string is different. I was expecting that the ConnectionString would override the InitialCatalog, but it does not seem to be the case. Which one really overrides the other? Can that behavior be altered? It does not appear that I can

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

我的未来我决定 提交于 2019-12-04 11:26:25
问题 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 partitioned by year and each year be partitioned by month as well. (2010/01, 2010/02, ... 2010/12, 2011/01, ... 2015/01...) E.X: Sales2010Jan, Sales2010Feb, Sales2011Jan, Sales2011Feb, Sales2012Dec, etc. My Question is: is it even possible? If it

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

和自甴很熟 提交于 2019-12-04 03:09:02
问题 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 start the job but I can't find any sample code to poll the msdb.dbo.sp_help_job to know when it is completed and then find out if it was successful or failed. 回答1: -- ============================================= -- Description: Starts a SQLAgent Job and

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

六眼飞鱼酱① 提交于 2019-12-03 06:18:50
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 partitioned by year and each year be partitioned by month as well. (2010/01, 2010/02, ... 2010/12, 2011/01, ... 2015/01...) E.X: Sales2010Jan, Sales2010Feb, Sales2011Jan, Sales2011Feb, Sales2012Dec, etc. My Question is: is it even possible? If it is, how an I automate the process using SSIS? Julien Vavasseur SSIS is an ETL (extract, transform, load)

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

為{幸葍}努か 提交于 2019-12-01 16:43:58
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 start the job but I can't find any sample code to poll the msdb.dbo.sp_help_job to know when it is completed and then find out if it was successful or failed. -- ============================================= -- Description: Starts a SQLAgent Job and waits for it to finish or until a specified wait period elapsed -- @result: 1 -> OK -- 0 -> still running

Increase TEXT SIZE in SQL Server Agent

六月ゝ 毕业季﹏ 提交于 2019-12-01 10:38:29
SQL Server Agent has a 512 characters limit on texts fields like nvarchar(max). I found this out after seeing my stored procedure is working correctly when I run it in SSMS but not working when is being run by a SQL Server job. To fix this I know I can use SET TEXTSIZE { number } in my stored procedure to increase this number. However I don't want to add this line in each and every stored procedure that are being run by SQL Server jobs. Is there a way that I can set this value for SQL Server agent itself? 来源: https://stackoverflow.com/questions/31063553/increase-text-size-in-sql-server-agent