Survey banner
The Dataiku Community is moving to a new home! We are temporary in read only mode: LEARN MORE

Call a stored procedure on MS SQL on Dataiku 11

Solved!
darioromero
Level 2
Call a stored procedure on MS SQL on Dataiku 11

Hi All:

In the past I was able to run a sotred procedure on PostgreSQL using this executor from Dataiku:
                                         from dataiku import SQLExecutor2

the call to the stored procedure looked like this and it was completely successful:

                                         executor = SQLExecutor2(connection=connection)

                                         df = executor.query_to_df(stored_proc_query)

I am trying to do the same on MS SQL and the 

executor.query_to_df(
    'EXEC stored_procedure_name '2023-08-01';
)

does not work the same. Have you tried this before? Have you guys experienced this before?

Thanks,

Dario


Operating system used: linux AWS

0 Kudos
1 Solution
darioromero
Level 2
Author

Thanks for the suggestion. Reason we are using it within a Python recipe is the call to execute the stored procedure has dynamic parameters. We call the stored procedure from MS SQL using a different argument every time.

I've managed to fix the issues. The Python recipe is executing the stored procedure using 

'EXEC stored_procedure_name '2023-08-01';

 and we got the required results.

Thanks very much.

BTW: On PostgreSQL we use 'Call'. On MS SQL we use 'EXEC'.

View solution in original post

2 Replies
JordanB
Dataiker

HI @darioromero,

Can you please try using "CALL" instead of "EXEC" here? We typically recommend running your procedures in SQL notebooks or SQL script recipes, just consider this documentation if you decide to call procedures inside SQL recipes.

Thanks,

Jordan

 

 

0 Kudos
darioromero
Level 2
Author

Thanks for the suggestion. Reason we are using it within a Python recipe is the call to execute the stored procedure has dynamic parameters. We call the stored procedure from MS SQL using a different argument every time.

I've managed to fix the issues. The Python recipe is executing the stored procedure using 

'EXEC stored_procedure_name '2023-08-01';

 and we got the required results.

Thanks very much.

BTW: On PostgreSQL we use 'Call'. On MS SQL we use 'EXEC'.