Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Join us at FabCon Vienna from September 15-18, 2025, for the ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM. Get registered

Reply
JE_test
Resolver I
Resolver I

Unable to create functions in Fabric Data Warehouse

Hi!

I was not sure in which forum this question fits, but I ended up here.

Has anyone here tried to create a function in Fabric Data Warehouse? I don't have much experience creating functions in SQL, so maybe I'm doing something wrong. But I'm not able to create either a scalar or table valued function, i always get the error: 

RETURNS @return_variable is not supported for CREATE/ALTER FUNCTION.

 

Is it even possible to create functions today i Fabric Data Warehouse? If so, what is the syntax? and what RETURN types are supported?

2 ACCEPTED SOLUTIONS
Anonymous
Not applicable

Hi @JE_test 
Apologies for the issue you have been facing.
When I tried to create a simple function without any parameters, the function was created successfully.

vnikhilanmsft_0-1705513219807.png

 

vnikhilanmsft_1-1705513244304.png


But scalar functions are not yet available in Fabric. For more information please refer to this link: Link1

vnikhilanmsft_2-1705513314639.png


vnikhilanmsft_3-1705513914841.png

 


Hope this helps. Please let us know if you have any further questions.

View solution in original post

Thanks for the additional examples.

 

I'm copying a function from a local SQL server, and it is a scalar function with variables.

 

But my workaround includes CTEs instead of variables, and returning a table with only one entry. I think it will work.

View solution in original post

6 REPLIES 6
JE_test
Resolver I
Resolver I

It seems like the syntax is slightly different if you declare variables inside the function. I tried to create a very simple function and still got the same error:

 

 

CREATE FUNCTION meta.testfunction (@TestID int)
returns varchar(200)
as
begin
declare  varchar(200)
select  = Namn from [datastore].[test]
where TestID = @TestID
return 
end
Msg 15869, Level 16, State 55, Procedure testfunction, Line 13 [Batch Start Line 0]
RETURNS <return_data_type> is not supported for CREATE/ALTER FUNCTION.

 

What return-values are even supported?

 

Edit: I forgot that I read that scalar functions are not yet supported... https://learn.microsoft.com/en-us/sql/t-sql/statements/create-function-sql-data-warehouse?view=aps-p...

Anonymous
Not applicable

Hi @JE_test 
Are you still facing this issue? If yes will respond back with the more details and we will try to help.
Thanks

Yes I still have the issue. Here is a simple function that gives an error, which is an extremely dumbed down version of what in trying to do. (take in a variable and return a date from another table).

Dummy-function:

CREATE FUNCTION [datastore].[fnDummy]
(@dummyID int)
RETURNS @T TABLE(N date)
AS
BEGIN
    DECLARE @NOW DATETIME
    SET @NOW = GETDATE()
	INSERT INTO @T SELECT @NOW
    RETURN 
END
GO

Error:

Msg 15869, Level 16, State 54, Procedure fnDummy, Line 24 [Batch Start Line 0]
RETURNS @return_variable is not supported for CREATE/ALTER FUNCTION.

 

 

Anonymous
Not applicable

Hi @JE_test 
Apologies for the issue you have been facing.
When I tried to create a simple function without any parameters, the function was created successfully.

vnikhilanmsft_0-1705513219807.png

 

vnikhilanmsft_1-1705513244304.png


But scalar functions are not yet available in Fabric. For more information please refer to this link: Link1

vnikhilanmsft_2-1705513314639.png


vnikhilanmsft_3-1705513914841.png

 


Hope this helps. Please let us know if you have any further questions.

Thanks for the additional examples.

 

I'm copying a function from a local SQL server, and it is a scalar function with variables.

 

But my workaround includes CTEs instead of variables, and returning a table with only one entry. I think it will work.

fabricator1
Advocate II
Advocate II

In this post, there is an example of a SQL Function which worked
 

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June FBC25 Carousel

Fabric Monthly Update - June 2025

Check out the June 2025 Fabric update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.