Page 1 of 1
Using a Stored Procedure in a SQL Data Connector
Posted: Thu Apr 15, 2021 3:34 pm
by jmckinstry
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.
Re: Using a Stored Procedure in a SQL Data Connector
Posted: Thu Apr 15, 2021 9:16 pm
by Jacob
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:
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
Re: Using a Stored Procedure in a SQL Data Connector
Posted: Fri Apr 16, 2021 5:38 pm
by jmckinstry
Perfect - thank you Jacob! Just what I was looking for.