# Can I call SQL Server stored procedures from Matillion?

**URL:** <https://matillioncommunity.discourse.group/t/can-i-call-sql-server-stored-procedures-from-matillion/1171>\
**Category:** Matillion ETL\
**Created:** [August 20, 2020, 10:52am UTC](https://matillioncommunity.discourse.group/t/can-i-call-sql-server-stored-procedures-from-matillion/1171 "2020-08-20T10:52:24Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![NK112421](https://avatars.discourse-cdn.com/v4/letter/n/b5a626/32.png) [@NK112421](https://matillioncommunity.discourse.group/u/NK112421)\
**Post date:** [August 20, 2020, 10:52am UTC](https://matillioncommunity.discourse.group/t/can-i-call-sql-server-stored-procedures-from-matillion/1171/1 "2020-08-20T10:52:24Z")

</div>

Good morning,

&nbsp;

Is there a way for me to run ad-hoc SQL Server queries that do not return a row set please? I would like to include administrative processes in my orchestrations.

&nbsp;

Nick

---

<div class="post-metadata">

**Author:** ![Bryan](https://avatars.discourse-cdn.com/v4/letter/b/db5fbb/32.png) [@Bryan](https://matillioncommunity.discourse.group/u/Bryan)\
**Post date:** [August 20, 2020, 9:51pm UTC](https://matillioncommunity.discourse.group/t/can-i-call-sql-server-stored-procedures-from-matillion/1171/2 "2020-08-20T21:51:21Z")

</div>

HI [@NK112421](https://matillioncommunity.discourse.group/u/NK112421)​, the only way that I know of to do this in Matillion is by using Python. Matillion doesn't have any components currently that will make calls to SQL Server in this fashion. Checkout using the PyODBC library, it's fairly mature and seems to do a decent job. Here is a good example of it can be used in a situation like you are asking for: [https://www.easysoft.com/developer/languages/python/examples/CallSP.html](https://www.easysoft.com/developer/languages/python/examples/CallSP.html)

I hope this helps.

---

<div class="post-metadata">

**Author:** ![NK112421](https://avatars.discourse-cdn.com/v4/letter/n/b5a626/32.png) [@NK112421](https://matillioncommunity.discourse.group/u/NK112421)\
**Post date:** [August 21, 2020, 5:43am UTC](https://matillioncommunity.discourse.group/t/can-i-call-sql-server-stored-procedures-from-matillion/1171/3 "2020-08-21T05:43:42Z")

</div>

Good morning Bryan,

&nbsp;

Thank you so much for the speedy answer. Python was the route I had initially chosen but being new the platform I had hoped that there was a trick that I was missing. I had IT pip install PyODBC yesterday. It is not a bad approach since you end up with the opportunity to parse and raise platform exceptions from the driver.

&nbsp;

Thanks for help.

&nbsp;

Cheers,

&nbsp;

Nick

&nbsp;

&nbsp;

---

<div class="post-metadata">

**Author:** ![Nils](https://avatars.discourse-cdn.com/v4/letter/n/d6d6ee/32.png) [@Nils](https://matillioncommunity.discourse.group/u/Nils)\
**Post date:** [November 24, 2020, 9:58am UTC](https://matillioncommunity.discourse.group/t/can-i-call-sql-server-stored-procedures-from-matillion/1171/4 "2020-11-24T09:58:34Z")

</div>

I faced the same challenge today.

Another solution that worked for me is using the DB Query Component.

e.g.

exec "stored procedure";

SELECT 1 AS TEST;

&nbsp;

The select part is to avoid the component returning an error message for not returning any values.

You can improve this as well by using an select that retrieves something useful data like some logs of the stored procedure.

&nbsp;

Keep in mind that you can't execute this code using the "sample" feature because the sample will generate a sub select so the code will not be valid.

&nbsp;

It is not the cleanest solution but it should work.

&nbsp;

---

<div class="post-metadata">

**Author:** ![Varada](https://avatars.discourse-cdn.com/v4/letter/v/e480ec/32.png) [@Varada](https://matillioncommunity.discourse.group/u/Varada)\
**Post date:** [May 22, 2021, 4:02pm UTC](https://matillioncommunity.discourse.group/t/can-i-call-sql-server-stored-procedures-from-matillion/1171/5 "2021-05-22T16:02:23Z")

</div>

I was able to use SQL Script component, and embed the "call Stored Procudure" for residing in snowflake. I believe this will be the same with other databases as well.

---

<div class="post-metadata">

**Author:** ![Bryan](https://avatars.discourse-cdn.com/v4/letter/b/db5fbb/32.png) [@Bryan](https://matillioncommunity.discourse.group/u/Bryan)\
**Post date:** [August 20, 2020, 10:54pm UTC](https://matillioncommunity.discourse.group/t/can-i-call-sql-server-stored-procedures-from-matillion/1171/6 "2020-08-20T22:54:34Z")

</div>

I forgot to mention that you will need to install the PyODBC library on your Matillion instance before you can use it in the Matillion software. This is explained in this document: [https://documentation.matillion.com/docs/2234735](https://documentation.matillion.com/docs/2234735) in the "Addition Modules" section.
