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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T04:45:26+00:00 2026-06-07T04:45:26+00:00

Why can I not use functions to directly assign stored procedure parameters? e.g. exec

  • 0

Why can I not use functions to directly assign stored procedure parameters?

e.g.

exec myStoredProc @firstParam = aFunctionThatReturnsAnAppropriateValue()

but I find I have to decalre a variable just to hold the value

declare @temp type = aFunctionThatReturnsAnAppropriateValue()

exec myStoredProc @firstParam = @temp

which seems redundant

  • 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-07T04:45:29+00:00Added an answer on June 7, 2026 at 4:45 am

    Quoting EXECUTE (Transact-SQL):

    Execute a stored procedure or function
    [ { EXEC | EXECUTE } ]
        { 
          [ @return_status = ]
          { module_name [ ;number ] | @module_name_var } 
            [ [ @parameter = ] { value 
                               | @variable [ OUTPUT ] 
                               | [ DEFAULT ] 
                               }
            ]
          [ ,...n ]
          [ WITH RECOMPILE ]
        }
    [;]
    

    You can see that it explicitly says @variable or value. I guess this is a language limitation, as you can neither write a call to a function as a variable or as a value; it is executable code (an expression), and the short-hand assignment during variable declaration is just a misleading bonus.

    EDIT: Compare the difference of description for DECLARE and EXECUTE:

    For DECLARE

    =value
    Assigns a value to the variable in-line. The value can be a constant or an expression, but it must either match the variable
    declaration type or be implicitly convertible to that type.

    When looking through the page for EXECUTE, I do not see the mention of an expression. It seems to me that it would be handy, as I think you are trying to point out.

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

Sidebar

Related Questions

I can not use content://sms? Works on all Android devices? I'm using SmsManager but
Both are delegates and have the same signature, but I can not use Action
Where can I find a RSA encrypt example that does not use NoPadding? --update
Because codenameone can not use external libraries (HttpConnection) then I have to use the
My question is, why I can not use hide() & show() to hide/show table
I can not get logs from some customers, can I use Google Urchin in
I have a SMTP account that does not use encrypted connection. I can use
I use a Mahout (version 0.8) and MySQL. I can not figure out how
I've spent whole days with PHP's DOM functions but i can't understand how it
I know you can assign a function's return value to a variable and use

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.