Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8896695
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T00:08:28+00:00 2026-06-15T00:08:28+00:00

I have defined function which returns table with 2 columns. Can I rename these

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T00:08:30+00:00Added an answer on June 15, 2026 at 12:08 am

    Is this what you mean?

    CREATE FUNCTION F_3
    (@press nvarchar(255))
    RETURNS @table TABLE ( [Press name]  nvarchar(255),
                       [Sum of pages] 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 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

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a C program which has a function call that is defined in
I have a wcf service which exposes a function that returns a complex type
I have defined a function in which i want to open a page on
I have defined a function in my Navigation model that executes a query, and
I have two models that I would like to present in a single Yii
Is this possible? I have a function which creates a table. I want a
I want to have a function that evaluates 2 bool vars (like a truth
I have in my application a user defined function which takes a comma separated
I have several user defined table-valued functions and one view which has the same
I have a database structure that has a Person table which contains fields such

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.