Using a Stored Procedure in a SQL Data Connector

Ranorex Spy, Recorder, and Studio.
jmckinstry
Posts: 18
Joined: Mon Sep 30, 2013 5:01 pm

Using a Stored Procedure in a SQL Data Connector

Post by jmckinstry » Thu Apr 15, 2021 3:34 pm

Is it possible to use a stored procedure in place of a SELECT query in the the Query section of the Data Source Config? Something like exec abcd?

Thank you for your help.

Jacob
Certified Professional
Certified Professional
Posts: 21
Joined: Mon Mar 22, 2021 10:01 pm

Re: Using a Stored Procedure in a SQL Data Connector

Post by Jacob » Thu Apr 15, 2021 9:16 pm

Hi jmckinstry,

My name is Jacob and I'm one of the engineers here at Ranorex. Thank you for your question! While I don't generally recommend using a Stored Procedure to return tables of data, it is possible to do this with Ranorex Studio. I created a simple SP that simply selects the first 5 rows from a table called employees in my database:

Code: Select all

CREATE PROCEDURE select_all_employees
AS
SELECT TOP(5) * FROM employees
GO; 
I was then able to call the SP with the following execute statement when setting up a SQL Server database connection for my solution:

Code: Select all

EXEC select_all_employees;
The code executed just fine and brought in a copy of the results into the solution so I could then iterate my tests. I would recommend caution with this method if you are working with complex Stored Procedures or large data sets. You can run into issues. That being said, this is a perfectly workable method if required by your use case.

--Jacob
Image

jmckinstry
Posts: 18
Joined: Mon Sep 30, 2013 5:01 pm

Re: Using a Stored Procedure in a SQL Data Connector

Post by jmckinstry » Fri Apr 16, 2021 5:38 pm

Perfect - thank you Jacob! Just what I was looking for.