TSQL, Rename column of a returning table in user Function
- by user1433660
I have defined function which returns table with 2 columns. Can I rename these columns so that resulting table would be like:
Press name | Sum of pages
?
CREATE FUNCTION F_3
(@press nvarchar(255))
RETURNS @table TABLE ( Press nvarchar(255),
PagesSum int )
AS
BEGIN
INSERT @table SELECT @press, SUM(Books.Pages)
FROM Books, Press
WHERE Press.Name = @press AND
Books.Id_Press = Press.Id
GROUP BY Press.Name
RETURN
END
GO
SELECT * FROM F_3('BHV')
GO
I've tried to do it like
Press AS 'Press name' nvarchar(255)
but that won't work.