Azure Synapse "Message Type Not Found" error when running stored procedure: Appears when lines of code reach certain line length

Michael King 0 Reputation points
2024-07-22T17:24:40.0233333+00:00

Hi,

We need some technical guidance from either a Azure Synapse specialist to resolve an issue which we are unable to understand / fix despite running through the sql logic bit-by-bit, line-by-line. Any guidance or help would be much appreciated.

We have a stored procedure in Azure Synapse Analytics which is erroring with a "Message Type Not Found" when the last select command goes past 1645 lines in the coding. The script has a last select command and lists out a set of fields to pull back the data.

The error message appears within the last select command just 6 fields / lines of code short of the end of the stored procedure. The stored procedure when run by a pipeline in Azure Synapse creates a table with the last 6 fields returning nulls.

On working through the script there are some interesting points:

1 - When spaces and comments are removed and the stored procedure header are all removed, then more fields can be added to the last select command without the error messaging appearing. Ie we can run the script with all the fields included in the last select command apart from the last field before the error message appears. It seems to suggest the error is related to the length of scripting.

2 - The error is not related to the specific fields being called as if you remove a field from higher up in the last select command then add the last field at the end, then the script will work without the error.

3 - The same script runs without any issues in Microsoft SQL Server Management Studio

4 - We are running the stored procedure and script on Azure Synapse Analytics with a serverless solution and so although i have read Microsoft Azure articles about resource classes and restrictions, this should not apply when using a serverless solution.

5 - We are running the scripting within the Azure Synapse Analytics web portal and running this via stored procedures and pipelines. We are also running the script by just highlighting and running the select commands listed within the stored procedure and still the error message is appearing.

6 - When using select * command pointing to the last cte / temp table and removing the line-by-line last select command which lists out every temp table field, then the script works without the error. This reduces the number of lines used in the last select command.

Any technical guidance to help us understand / resolve our issue would be much appreciated.

Many thanks.

Mike King

Azure Synapse Analytics
Azure Synapse Analytics
An Azure analytics service that brings together data integration, enterprise data warehousing, and big data analytics. Previously known as Azure SQL Data Warehouse.
4,997 questions
SQL Server Analysis Services
SQL Server Analysis Services
A Microsoft online analytical data engine used in decision support and business analytics, providing the analytical data for business reports and client applications such as Power BI, Excel, Reporting Services reports, and other data visualization tools.
1,290 questions
{count} votes

1 answer

Sort by: Most helpful
  1. NIKHILA NETHIKUNTA 3,265 Reputation points Microsoft Vendor
    2024-08-20T16:26:05.51+00:00

    Hi @Michael King
    Your inference about the character limit for stored procedures in Azure Synapse Analytics is indeed correct. The maximum size for a stored procedure in Synapse Analytics is limited to 64 KB (approximately 65,536 characters). This limit is in place to ensure optimal performance and manageability within the system.

    If you find that your stored procedure exceeds this limit, you might consider breaking it down into smaller, modular procedures or optimizing the code to fit within the constraints.

    For more information, please refer to the below link:
    https://learn.microsoft.com/en-us/azure/synapse-analytics/synapse-link/synapse-link-for-sql-known-issues

    Hope this helps. Do let us know if you any further queries.


    If this answers your query, do click Accept Answer and Yes for was this answer helpful. And, if you have any further query do let us know.

    1 person found this answer helpful.

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.