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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T18:51:54+00:00 2026-05-24T18:51:54+00:00

EDIT : Based on answers below I added dbo. and comments for clarification. Question

  • 0

EDIT: Based on answers below I added “dbo.” and comments for clarification.

Question: How do I pass a SQL user-defined function (UDF) as an argument for another UDF? Note that the function returns a table.

select dbo.fn_Scalar()                      -- Returns 'sa'.
select * from dbo.fn_Tabler('sa')           -- Returns a table (not scalar).
select dbo.fn_ScalarArg(dbo.fn_Scalar())    -- Returns 'sa'
select * from dbo.fn_Tabler(dbo.fn_Scalar())    -- ERROR: Incorrect syntax near '.'.

(Currently using SQL Server 2008 R2)


EDIT: To ease debugging, here is the sample code to create the above functions:

IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[fn_Scalar]') AND type in (N'FN', N'IF', N'TF', N'FS', N'FT'))
DROP FUNCTION dbo.fn_Scalar
GO
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[fn_Tabler]') AND type in (N'FN', N'IF', N'TF', N'FS', N'FT'))
DROP FUNCTION dbo.fn_Tabler
GO
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[fn_ScalarArg]') AND type in (N'FN', N'IF', N'TF', N'FS', N'FT'))
DROP FUNCTION dbo.fn_ScalarArg
GO

create function fn_Scalar()
returns char(200) as
begin
    declare @user char(200)
    select  @user = 'sa'
    return  @user
end
GO

create function fn_Tabler(@User char(200))
returns table as
    return select @User [User]
GO

create function fn_ScalarArg(@User char(200))
returns char(200) as
begin
    declare @u2 char(200)
    select  @u2 = @User
    return  @u2
end
go
  • 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-24T18:51:56+00:00Added an answer on May 24, 2026 at 6:51 pm

    BOL says: “Scalar-valued functions must be invoked by using at least the two-part name of the function.”

    select * from dbo.fn_Tabler(dbo.fn_Scalar())    
    

    EDIT:
    I was wrong, there is the table-valued function… Documentation says that only constants and @local_variables can be passed to table-valued functions (see here)

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

Sidebar

Related Questions

Edit: Below is my working code based on the feedback/answers I recieved. This question
EDIT 2 Okay, based on the advice on the answers below I eliminated my
EDIT, Changed the code slightly based on answers below, but still haven't got it
UPDATE: Solved. Thanks BusyMark! EDIT: This is revised based on the answer below from
EDIT: Based on one of the posts below, i figured out how to write
EDIT: Based on evolution of the problem, I edited this question. First of all,
[EDIT] Based on feedback yes, VS2010 seems to support SL4 Library TDD despite a
There are already jQuery based Edit in place plug ins available. But i am
I would like to display certain meta data fields in the edit form based
I have a dialog-based app with an edit-control in it. When I minimize /

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.