Scalar Function in Azure Synapse A

Siddiqui, Bashir 41 Reputation points
2022-01-25T04:17:30.127+00:00

I am trying to create UDF Scalar Function in Azure Synapse Analytics, but I am getting the error given below. I am trying to create table variable or temp table inside the Scalar Function but getting an error.

Msg 105041, Level 16, State 1, Line 9
The SELECT statement is not allowed in user-defined functions.

SELECT @min = MIN(id) , @Max = MAX(id) FROM #Temp

WHILE (@min IS NOT NULL AND @min <= @Max )

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,696 questions
0 comments No comments
{count} votes

Accepted answer
  1. HimanshuSinha-msft 19,386 Reputation points Microsoft Employee
    2022-01-25T21:12:16.793+00:00

    Hello @Siddiqui, Bashir ,
    Thanks for the ask and using Microsoft Q&A platform .
    As I understand the ask here is how to use a SELECT statement in a scalar function in Synapse , please do let me know if thats not the case .

    Unfortunately at this time we cannot use a SELECT statement in the body of the function . Please read about this more here

    168521-image.png

    We can use a SELECT in table valued function which is called out here . Adding a example with the snashot for clarity below .

    168470-image.png

    We request to please go ahead and log a feature request on the feedback portal .
    https://feedback.azure.com/d365community/forum/9b9ba8e4-0825-ec11-b6e6-000d3a4f07b8#

    Product group does monitor the request and they can plan for the implementation in future .Once you log the feature request you will also be notified on the status of the request .

    Please do let me know how it goes .
    Thanks
    Himanshu

    -------------------------------------------------------------------------------------------------------------------------

    • Please don't forget to click on 130616-image.png or upvote 130671-image.png button whenever the information provided helps you. Original posters help the community find answers faster by identifying the correct answer. Here is how
    • Want a reminder to come back and check responses? Here is how to subscribe to a notification
    • If you are interested in joining the VM program and help shape the future of Q&A: Here is how you can be part of Q&A Volunteer Moderators
    0 comments No comments

0 additional answers

Sort by: Most helpful