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 7022541
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T23:35:45+00:00 2026-05-27T23:35:45+00:00

I’m reading Microsoft’s 70-433 SQL Training Kit, and I’ve come up against an example

  • 0

I’m reading Microsoft’s 70-433 SQL Training Kit, and I’ve come up against an example where they define the following as a “scalar UDF”:

CREATE FUNCTION dbo.fnGetCustomerAccountNumber(@CustomerID INT)
RETURNS VARCHAR(10)
AS
BEGIN
    RETURN ISNULL(
        (
        SELECT
            AccountNumber
        FROM Sales.Customer
        WHERE CustomerID = @CustomerID
    ), 'NOT FOUND');
END
GO

I understand that a scalar UDF (as oppposed to a table-valued one) is one that returns a single value, but it seems to me that the above function will only return a single value if there is only one row returned by the SELECT statement – which will depend on the contents of the table. But I’m happy to assume that there will be only one row returned (what would happen if there wasn’t?). But…

They then give an alternative version, which instead of calling the above UDF, does the following:

SELECT 
    soh.SalesOrderID
    , soh.OrderDate
    , ISNULL(
        (
        SELECT
            AccountNumber
        FROM Sales.Customer
        WHERE CustomerID = soh.CustomerID
    ), 'NOT FOUND')
FROM Sales.SalesOrderHeader AS soh;

They contrast this second example by saying “The use of inline table-valued UDFs does not incur the same performance penalty as the use of scalar UDFs because…”

So, this second example, even though the code is identical to the first, is a table-valued UDF rather than a scalar one? Is this an error in the text, or am I misunderstanding the distinction between a scalar UDF and a table-valued one?

  • 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-05-27T23:35:46+00:00Added an answer on May 27, 2026 at 11:35 pm

    There is a difference. Look at the where clause in the first

       WHERE CustomerID = @CustomerID
    

    Is matching CustomerID against a single integer value (which is a parameter.)

    In the 2nd where clause

       WHERE CustomerID = soh.CustomerID
    

    Is matching against every value of CustomerID in the Sales.SalesOrderHeader table.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
i got an object with contents of html markup in it, for example: string
I am using Paperclip to handle profile photo uploads in my app. They upload
I am reading a book about Javascript and jQuery and using one of the
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I am trying to understand how to use SyndicationItem to display feed which is
That's pretty much it. I'm using Nokogiri to scrape a web page what has

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.