This question already has an answer here:
- SQL Server 2008 - How do i return a User-Defined Table Type from a Table-Valued Function? 4 answers
Is it possible that a multi-statement UDF return a User Defined Table Type, instead of a table that is defined within it's return param?
So instead of:
CREATE FUNCTION MyFunc
(
@p1 int, @p2 char
)
RETURNS
@SomeVar TABLE
(
c1 int
)
AS
I would like to do:
CREATE FUNCTION MyFunc
(
@p1 int, @p2 char
)
RETURNS
@SomeVar MyTableType
AS
The reason for this is that inside my function I call other functions and have to pass in MyTableType UDT, even if I define exactly the same table definition in the RETURN table type, it will throw an operand clash error.