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.
Is this what you mean?
I just changed the RETURNS line of your function.
Apart from that, this function will perform poorly as it’s not an inline table valued function. Look at the example MSDN gives at http://technet.microsoft.com/en-us/library/ms177499(v=sql.90).aspx