> For the complete documentation index, see [llms.txt](https://brixxbox.gitbook.io/brixxbox-documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://brixxbox.gitbook.io/brixxbox-documentation/configuration/apps/sqlstoredprocedure.md).

# SqlStoredProcedure

### SQL Stored Procedure

This app allows you to maintain SQL stored procedures for your workspace DataBase.

In the main editor window you can edit the body of the procedure. The Create/Alter and procedure name must be omitted. After saving the stored procedure will be checked for errors. If no Errors are found it will be added to your DataBase.

It is always good practice to add a brief description for your function. This description is searchable within the list.

Once the stored procedure is successfully added to your DataBase you can directly test it from the query window. Enter your test and execute it. Errors or results will be shown. If u enter multiple tests in the query window, select the one you want by marking the relevant text. If a selection is active, only this will be executed.

### Example Usages

Only write the body of the procedure! Is this case the **CREATE PROCEDURE ExampleDateToVeryLongString** is automatictly generated.

```sql
@aReturnString nvarchar(255) output
AS
BEGIN

    DECLARE @DayAsString nvarchar(max);

    SET @DayAsString =   
        CASE   
            WHEN DAY(getdate()) = 1 THEN '1st'  
            WHEN DAY(getdate()) = 2 THEN '2nd'  
            WHEN DAY(getdate()) = 3 THEN '3rd'  
            ELSE DATENAME(day, getdate()) + 'th'
        END; 

	SET @aReturnString = ( DATENAME(weekday, getdate()) 
	       + ' ' +  @DayAsString + ' of ' 
		   + DATENAME(month, getdate()) 
		   + ' in the Year ' + DATENAME(YEAR, getdate())
	);
END;
```

\
This can be checked in the test window.

```sql
DECLARE @someReturn nvarchar(255);

EXECUTE dbo.ExampleDateToVeryLongString @someReturn output;

SELECT @someReturn;
```


---

# 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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://brixxbox.gitbook.io/brixxbox-documentation/configuration/apps/sqlstoredprocedure.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
