Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How to trigger and find status of sql job through c#?

Posted on 2013-11-10
3
Medium Priority
?
1,121 Views
Last Modified: 2013-11-30
I have an requirement in which SQL server job needs to be trigger through C# and show the status in web application from its start to end.

SQL server job has to fetch data from excel file and loading it to the SQL Server 2008 R2 database which has minimum of 25000 rows and maximum of any.

Please help in resolve this.

Thanks in advance.
0
Comment
Question by:devmasters
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 23

Expert Comment

by:Michael Fowler
ID: 39637764
If you create the sql job as a stored procedure you can then use print statements in the proc to provide updates to the web app

http://www.nullskull.com/faq/1131/view-print-statements-in-your-stored-procedures-in-c-via-adonet.aspx

Michael
0
 

Accepted Solution

by:
devmasters earned 0 total points
ID: 39676664
SqlConnection DbConn = new SqlConnection(sqlConnection);
            SqlCommand ExecJob = new SqlCommand();
            ExecJob.Connection = DbConn;
            ExecJob.CommandType = CommandType.StoredProcedure;
            ExecJob.CommandText = "msdb.dbo.sp_start_job";
            ExecJob.Parameters.AddWithValue("@job_name", "LoadData");

            using (DbConn)
            {
                DbConn.Open();
                using (ExecJob)
                {
                    ExecJob.ExecuteNonQuery();
                }
            }
0
 

Author Closing Comment

by:devmasters
ID: 39686702
It is perfectly working as expected
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article I will describe the Detach & Attach method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question