cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Questions
Helper I
Helper I

Possible to run an SQL Agent Job?

I have several agent jobs that it would be EXTREMELY helpful if Power Apps could run them (load and refresh some data from a feed).

 

Has anyone else done this?  They would be on an SQL Server that lives in IaaS not as Azure SQL Service.

7 REPLIES 7
Thealster
Helper I
Helper I

Agent jobs usually run as scheduled tasks. What you could try is to create stored procedures and run these from triggers in the table being updated by PowerApps data?  Would that work?

Yes, that would be an option.

 

I take it there is no way to call a stored procedure from power apps directly?

 

That said, yeah I could make a table and then have the stored procedure UPDATE that table's record with "processing" and "completed" and then Power Apps could just refresh that view waiting for it to finish so the user gets confirmation when all is done.

cpl123
New Member

That would be very nice if that was possible. I'm also looking for something like this

I read somewhere just recently that there was a way to now call stored procs from PowerApps. 

 

Does anyone one know how this can be done?

That would be helpful. I need this functionality also. Otherwise the trigger on value change idea will be necessary but not very neat as we are looking for code free solutions from Power apps.

Solved - The SQL Server connector does have this operation as standard. Namely Operation ID: ExecuteProcedure Called Execute Stored Procedure

 

Let's try it out.  Let me know how you go.

 

David Taylor

FAST LANE BUSINESS INTELLIGENCE

www.fastlanebi.com

 

 

AndreWx01
Regular Visitor

Hola!!

  No hablo ingles, pero lo puedes traducir …

 

 

  • Modificar y Crear SP_START_JOBV2 
    • Crear solo 1 variable
    • Declarar las demas 
CREATE PROCEDURE [dbo].[sp_start_jobV2]
  @JOB_name    sysname
  
AS
BEGIN
  DECLARE @JOB_id_as_char VARCHAR(36)
  DECLARE @retval         INT
  DECLARE @SteP_id        INT
  DECLARE @JOB_owner_sid  VARBINARY(85)
  DECLARE @JOB_id      UNIQUEIDENTIFIER = NULL
  DECLARE @error_flag  INT              = 1   -- Set to 0 to suppress the error from sp_sqlagent_notify if SQLServerAgent is not running
  DECLARE @server_name sysname          = NULL -- The specific target server to start the [multi-server] job on
  DECLARE @SteP_name   sysname          = NULL -- The name of the job step to start execution with [for use with a local job only]
  DECLARE @output_flag INT              = 1     -- Set to 0 to suppress the success message
  • Crear nuevo SP , para llamar Job
ALTER PROCEDURE [dbo].[llamar_job] 
 @LLAMAR varchar (50)
	
	AS
BEGIN

      exec msdb.dbo.sp_start_jobV2 @llamar

END
  • Power Automate > Flow > Button PowerApps

AndreWx01_1-1626277546918.png

  • Test Flow

 

AndreWx01_2-1626277767043.png

 

  • AndreWx01_3-1626277832166.png

     

  • AndreWx01_4-1626277882511.png

     

 

Saludos

 

 

 

Helpful resources

Announcements
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Difinity Conference 2022

Difinity Conference 2022

Register today for two amazing days of learning, featuring intensive learning sessions across multiple tracks, led by engaging and dynamic experts.

European SharePoint Conference

European SharePoint Conference

The European SharePoint Conference returns live and in-person November 28-December 1 with 4 Microsoft Keynotes, 9 Tutorials, and 120 Sessions.

Power Apps Ideas

Changes to Ideas Coming

We are excited to announce a new way to share your ideas for Power Apps!

Top Solution Authors
Top Kudoed Authors
Users online (5,012)