Firstly create the stored procedure you wish to run in Azure SQL
Here’s a simple procedure which triggers and update query that inserts records into table 34 from a view based on a flag in the table saying transform is 1 it then runs another query to set the transform field to 0 to prevent the insert happening again the next time.
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE Procedure [dbo].[transformemail]
AS
SET NOCOUNT ON;
INSERT INTO t034 (pkid,body1,eplanno,money4,trandate,payref,wlcref,tranid,email,updated)
SELECT pkid,body1,eplanno,money4,trandate,payref,wlcref,tranid,email,updated
FROM v031;
UPDATE t032email
SET transform = 0
WHERE t032email.transform = 1;
GO
Firstly navigate to the form you wish to put the code into and insert a button into that form.
![](https://cloudydatablog.net/wp-content/uploads/2020/12/a-1024x601.png)
Next using your mouse select the button and on the right hit the button marked Edit button code
![](https://cloudydatablog.net/wp-content/uploads/2020/12/a-1.png)
This reveals the Button Properties window dialogue
![](https://cloudydatablog.net/wp-content/uploads/2020/12/a-2.png)
Please note there are three tabs at the top here marked
Client Before Server and Client After – we will be placing code in all of them so take note
![](https://cloudydatablog.net/wp-content/uploads/2020/12/a-3.png)
In the Client Before tab I enter.
params["txt"] = "Transformation";
ajax.setMessage("Sending request to server...");
// Uncomment the following line to prevent execution of "Server" and "Client After" events.
// return false;
![](https://cloudydatablog.net/wp-content/uploads/2020/12/a-8.png)
In the Server tab I enter
tDAL.CustomQuery ("EXEC dbo.transformemail");
result["txt"] = parameters["txt"].ToString() + " complete";
![](https://cloudydatablog.net/wp-content/uploads/2020/12/a-6.png)
And in the Client after tab I enter
// Put your code here.
var message = result["txt"] + " !!!";
ajax.setMessage(message);
![](https://cloudydatablog.net/wp-content/uploads/2020/12/a-7.png)
Now build the project and when you hit the button on the web client your procedure will be run on the server.
![](https://cloudydatablog.net/wp-content/uploads/2020/12/a-9-1024x264.png)
![](https://cloudydatablog.net/wp-content/uploads/2020/12/a-10.png)
![](https://cloudydatablog.net/wp-content/uploads/2020/12/a-11-1024x592.png)