> For the complete documentation index, see [llms.txt](https://docs.servoy.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.servoy.com/reference/servoycore/dev-api/datasources/spdatasource.md).

# SPDataSource

## Overview

Access and execute stored procedures dynamically at runtime from any enabled data source using the `datasources.sp` object.

Runtime Access to Stored Procedures in `datasources.sp`##

The `datasources.sp` object provides runtime access to all stored procedures enabled across supported data sources. This access allows dynamic execution of procedures directly within Servoy’s scripting environment, enabling developers to interact with the database more flexibly without needing SQL statements.

### Enabling Stored Procedures

To make stored procedures accessible in your solution:

1. Open the configuration settings for your database server.
2. Under Advanced Server Settings, check the **Enable Procedures** option to allow stored procedures to appear.
3. **Restart** Servoy Developer to apply the changes.

After enabling, stored procedures appear under the Procedures node in the solution explorer. This setup allows the procedures to be accessed directly in code via the `datasources.sp` object.

**Example:** Accessing stored procedures under a server

```js
var dataset = datasources.sp.myserver.mystoredprocedure(param1, param2);
```

### Accessing Stored Procedures

The `datasources.sp` structure organizes stored procedures by server. The syntax for accessing a procedure follows this format:

* `datasources.sp.<servername>.<storedProcedureName>()`

This syntax is available with code completion, making it easy to view and select from available stored procedures for each server.

### Use Case Examples:

* **Data Retrieval**: Retrieve filtered datasets or calculated results from stored procedures, improving performance by handling data operations within the database.
* **Batch Processing**: Use stored procedures for complex, multi-step operations that are better handled by the database itself.

### Remarks

* **Execution Context**: The logic within stored procedures is managed within the database. Any required changes to procedure logic should be handled in the database environment.
* **In-Memory Data Source Support**: You can create an in-memory data source (temp table) directly from a stored procedure’s dataset, which is useful for handling temporary data during a session.
* **Error Handling**: Procedures may throw database-side exceptions; handling these at the database layer will prevent disruption in the Servoy client.

For details on how to use Stored Procedures with Servoy, refer to the [Procedures](https://docs.servoy.com/guides/develop/application-design/data-modeling/databases/procedures) section of this documentation.

***


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.servoy.com/reference/servoycore/dev-api/datasources/spdatasource.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
