I Have a UDF that returns a TABLE.
In my SP i define a temp table variable:
declare @t table ([ID] uniqueidentifier)
How do I set @t = MyDF
?
Only method that works is:
INSERT INTO @t SELECT * FROM dbo.MyUDF(@List)
This does not work:
SELECT * INTO @t FROM dbo.MyUDF(@List) -- <- This is just a note, and NOT the question
My Question: Can't I just somehow assign select @t = dbo.MyUDF
?
Is there any other way to directlly assign the UDF result TABLE to the temp variable other than actually "INSERT INTO"
/"SELECT INTO"
EDIT: I know I can reference dbo.MyUDF()
in my query directly without using a temp table variable. but since I need to reference this a few times in my SP, I prefer to work with a local variable which will be assigned only once, and not process dbo.MyUDF()
each time I reference it.
My UDF is very much the same as in this answer: https://stackoverflow.com/a/11105413/3933402 (SplitInts
- only mine returns uniqueidentifier)