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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T21:45:06+00:00 2026-05-18T21:45:06+00:00

Hey all, I have a stored procedure and I need to call it within

  • 0

Hey all,
I have a stored procedure and I need to call it within another stored procedure, but I want the first one to return a value (field value).

CREATE PROCEDURE rnd_STR
(
    @Length int

)

@alphaVar varchar(10) OUTPUT
AS
SET @alphaVar = 'blah'

 #procedure body
END
GO

DECLARE @alphaVar varchar(10)

EXEC rnd_STR @alphaVar output

SELECT @alphaVar

ERRORS

Msg 102, Level 15, State 1, Procedure rnd_STR, Line 6

Incorrect syntax near ‘@alphaVar’.

Msg 137, Level 15, State 1, Procedure rnd_STR, Line 8

Must declare the scalar variable “@alphaVar”.

Msg 2812, Level 16, State 62, Line 4

Could not find stored procedure ‘rnd_STR’.

(1 row(s) affected)

didn’t work !!

How can I call it??

BTW, the returned @ID is a string

  • 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-18T21:45:07+00:00Added an answer on May 18, 2026 at 9:45 pm

    You say @alphaVar is varchar(10). In that case you need to use an output parameter as below. Return can only be used for integer types in stored procedures.

    CREATE PROCEDURE rnd_STR
    @Length int,
    @alphaVar varchar(10) OUTPUT    
    AS
    BEGIN
    SET @alphaVar = 'blah'
    /* Rest of procedure body*/
    END
    
    GO
    
    DECLARE @alphaVar varchar(10) 
    
    EXEC rnd_STR 10, @alphaVar output
    
    SELECT @alphaVar
    

    Alternatively you could use a scalar UDF rather than a stored procedure.

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

Sidebar

Related Questions

Hey all this is the first time i am calling a stored procedure via
Hey all, I have been doing nothing but web development over the last few
Hey all i have two JFrames one is my main login frame, user enters
Hey all- I have looked this up on here and Google but none of
Hey I have a question for javascript. I need to assign an href value
Hey all, I have something of an interesting requirement for my project. I need
Hey all. I have a question on how to implement the following with Django.
Hey all, basically i have an empty AS3 fla file with just the following
Hey all, i have been trying for a few minutes on this problem and
Hey all, i have a problem with trying to get 2 forms to close

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.