SQL Server job activity (job failed but history records in job activity still showing 'running' status ) - sql

I am checking one SSIS job execution report, which shows me the below report:
The most recent one succeeded, but when you take a look at ID:217583, it is still running and never finished (duration keeps increasing), and when I check the job activity in sql server agent, that execution should failed before, the reason why I said that was because the start time matched. Here is the job history in sql server agent :
So I assume this job execution failed but for some mystery reason, it still shows (or running) in the background with 'running ' status.
Does anybody have any ideas? I tried to EXEC msdb..sp.stop_jobscommand, but cannot locate that job ID.
Can anybody tell me what was really happened? Is this job still running somewhere else? If so, how to locate that job execution and stop it? Or how to let the report does not show this weird record anymore?
Thx in advance :)

If your are executing this package as a job from the SSISDB, you can use the stop operation procedure as follows.
USE SSISDB
GO
EXEC [catalog].[stop_operation] 217583
https://msdn.microsoft.com/en-us/library/hh213131.aspx here is a reference to stopping operations. In case this link breaks, ...
The SSISDB database stores execution history in internal tables that are not visible to users. However it exposes the information that you need through public views that you can query. It also provides stored procedures that you can call to perform common tasks related to packages.
Typically you manage Integration Services objects on the server in SQL Server Management Studio. However you can also query the database views and call the stored procedures directly, or write custom code that calls the managed API. SQL Server Management Studio and the managed API query the views and call the stored procedures to perform many of their tasks. For example, you can view the list of Integration Services packages that are currently running on the server, and request packages to stop if you have to.
Viewing the List of Running Packages
You can view the list of packages that are currently running on the server in the Active Operations dialog box. For more information, see Active Operations Dialog Box.
For information about the other methods that you can use to view the list of running packages, see the following topics.
Transact-SQL access
To view the list of packages that are running on the server, query the view, catalog.executions (SSISDB Database) for packages that have a status of 2.
Programmatic access through the managed API
See the Microsoft.SqlServer.Management.IntegrationServices namespace and its classes.
Stopping a Running Package
You can request a running package to stop in the Active Operations dialog box. For more information, see Active Operations Dialog Box.
For information about the other methods that you can use to stop a running package, see the following topics.
Transact-SQL access
To stop a package that is running on the server, call the stored procedure, catalog.stop_operation (SSISDB Database).
Programmatic access through the managed API
See the Microsoft.SqlServer.Management.IntegrationServices namespace and its classes.
Viewing the History of Packages That Have Run
To view the history of packages that have run in Management Studio, use the All Executions report. For more information on the All Executions report and other standard reports, see Reports for the Integration Services Server.
For information about the other methods that you can use to view the history of running packages, see the following topics.
Transact-SQL access
To view information about packages that have run, query the view, catalog.executions (SSISDB Database).
Programmatic access through the managed API
See the Microsoft.SqlServer.Management.IntegrationServices namespace and its classes.

Related

Use Linked Server in Execute SQL Task within SSIS Package

I have a package that has a main sql execute task. Within that task I need to call two databases (A,B) each on a different server. There is a linked server(B) within the main server(A) I am using. I can't split them out however due to they join on each other many times on many different tables in separate scripts. The main script is a large amount of unions pulling data in to report off of in a later task.
I have my linked server call in my sql script but it says it can't connect. Is there a way I can connect to this linked server as I do when I run the sql script from sql server? Or is there a way to make a connection within the SSIS package and refer to it somehow within a task or in the script?
Make sure Proxy Account has setup proper Login credential/user with permission to execute your task at main server(A) and able to access linked server(B).
Use Log Viewer at SSMS to see the error message.
See example at following URL:-
https://www.mssqltips.com/sqlservertip/2163/running-a-ssis-package-from-sql-server-agent-using-a-proxy-account/

Updating System variables in SSIS package

Similar to this post
I have an SSIS Package with a Script Task that creates an Excel file on disk and populates it with data from a SQL Stored Procedure (using Microsoft.Office.Interop.Excel). This works great when testing and when running the deployed package manually through the SSIS Catalog, but when I schedule the task to run automatically through SQL Server Agent, the Package fails in the Script Task step. I have the Job running as a Proxy account that is the same as the account I'm logged into the server with when testing (and the same as the account that works when manually running the packages).
My understanding is that even though the job is running using a Proxy, any desktop interaction occurs within the Profile context of the SQL Server Agent login. Since that profile isn't actively logged in, the interaction fails. Digging in more, there is a bool System Variable in the package called "InteractiveMode" that is set to "False". I have a feeling that if I could switch that to True, everything would be hunky dorey. Trouble is, that variable is only accessible to my Script Task as "ReadOnly"...
Is there any way to set the System:InteractiveMode Variable in an SSIS package manually or programatically at runtime? Please help! I'm having to run these scheduled jobs manually for now, which is a big pain.
Thanks.
I had this problem a few months ago and it turned out that the execution options needed to be set to use 32 bit runtime. If you're using SQL Server 2008 R2, you can open your job and double click on the step. It's under the Execution Options tab.
If you continue to have errors, you may want to consider changing the package so that it uses a file system task to create/rename the excel document and then a Data Flow Task to move the data from your stored procedure to your excel document. Depending on your data, you may need to add a Data Conversion step in between. Here's a good article on the topic: http://www.mssqltips.com/sqlservertip/3046/sql-server-integration-services-data-type-conversion-testing/
Edit:
I haven't used SQL Server 2012 yet, but according to MSDN, it looks like the option is under the Configuration tab. Here's their article: http://msdn.microsoft.com/en-us/library/gg471507(v=sql.110).aspx

Triggering a SQL job from inside a VB .NET application

I've searched similar topics looking for something closer to what I need, but I haven't had any luck yet. I'm working on a card ID import application, where I need to trigger a SQL job from the user's workstation to import the data into a different database. I did see one post about triggering a job locally from the command line on the local SQL server, but I need to see if I can do this remotely from inside the .NET application.
I already have a connection to the SQL server so that I can import the user information into the photo ID database, but once they have been imported, I need to kick off the scheduled job to run so that it will complete the process.
Use ADO.NET and send the following stored procedure sp_start_job (Transact-SQL) to the msdb db. Here is the MSDN docs.
http://technet.microsoft.com/en-us/library/ms186757.aspx

SQL server job not listed under SQL Server Management studio jobs list

I have generated a script for the SQL Server Agent job that I created.
However, when I run the script even though the job is created successfully (able to verify it through sysjobs_view system view) but it does not get listed under SQL Server Agent jobs list.
Does anyone know what the issue could be?
Thanks!
If dbrosier's suggestion to refresh the list doesn't work, I would check to see if you have a filter set on your jobs list. I would also wonder if it's a permissions issue, but in that case, you shouldn't be able to see any of the jobs and should get an error.

Is it possible to automate MS SQL Server (2005) queries via SQL Server Management Studio?

I have two queries saved on my SQL Server 2005 and I would like to have them running at certain intervals, e.g. every 24 hours. Is there a way to automate these queries and schedule them via SQL Server Management Studio?
You need to use the SQL Server Agent, installed as part of SQL Server. This is the background service that's responsible for running scheduled maintenance and backup tasks.
Expand the SQL Server Agent node in SQL Server Management Studio, you should see a tree node called "Jobs"
Right-clicking this will give you the option to add a new job. Jobs consist of a series of steps to be executed in order, and when you add a new step to your job, you can choose various types of step, including "Transact-SQL Script"
Create a new job, add a single T-SQL step, put the queries that you want to run into the step properties, and then use the "Schedule" option in the Job properties to create a recurring schedule that'll run the job every 24 hours (or whenever).
You can use the SQL Server Agent, which will allow the server to run the script/stored procedure.
You can also use the Windows Task Scheduler, either on the server or on any other server or workstation to schedule isqlw/sqlcmd to execute your script/stored procedure.
Create a job with a step in which you execute your queries; the job can be scheduled at your needs.
At a previous employer the operations department had a task sheduling application. They prefered to use the command line tools that come with sql server to execute jobs (stored procedures) on a scheduled basis. This way the "task scheduling application" could recieve an exit status (pass/fail, ok/error) and hold up dependent jobs.
I'm sorry I don't remember the name of the command line tool, but it was part of the sql server distro. I also do not remember the name of the task scheduling application. It was not the windows task scheduler. It was something enterprise level used to manage the nightly cycle.
Not sure of the scale of your project, but this is another way to go.
SKapsal's comment on a command line tool for executing SQL commands is a reference to osql (for SQL2000) or sqlcmd (for SQL2005+). You could save your script a file and run it from that command line using Windows Task Scheduler or something similar.
SQL Agent is still the preferred solution, however, as it provides GUI controls for job creation, scheduling, logging and viewing job execution history/results.
how to schedule a job for sql query to run daily?
This is similar question with helpful answer.
Covering simple step by step manual.