In my stored procedure, I have table variable with a lot of columns. Because I want to simplify the stored procedure I thought i could declare table variable in function like
CREATE FUNCTION [dbo].[ufn_DeclareMaterialTableVariable] ( ) RETURNS @returntable TABLE ( [Id] [int] NULL, [Number] [int] NOT NULL, [Name] [nvarchar](255) NULL, ... dozens of columns ) AS BEGIN RETURN END
but i realized i don't know, how to use it. My idea was something like
select * into @table from [dbo].[ufn_DeclareMaterialTableVariable]
but this is not gonna work, unless i use temporary table.
The second idea is to declare table with custom data type.
declare @table TABLE as CustomTableType
but this is also not working. Any idea ?