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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T02:44:58+00:00 2026-06-17T02:44:58+00:00

I have a question, I have a Stored Procedure which returns a value. This

  • 0

I have a question, I have a Stored Procedure which returns a value. This Stored Procedure is being executed within another SP and I need to transfer the value into this SP. How can I accomplish this.

Any help will be appreciated.

Thank you

Example:

CREATE PROC [dbo].[isp_CREATE_CONFIG]

@CFG_KEY VARCHAR(15)
, @CFG_SHORTVALUE INT
, @CFG_LONGVALUE VARCHAR(200)
, @CFG_DESC VARCHAR(250)
, @CFG_SHORT_DESC VARCHAR(100)
, @CFG_MISC1 VARCHAR(50)
, @CFG_MISC2 VARCHAR(50)
, @CFG_MISC3 VARCHAR(50)
, @CFG_MISC4 VARCHAR(50)
, @CFG_MISC5 VARCHAR(50)
, @CFG_USER VARCHAR(20)
, @CFG_MSG VARCHAR(250) OUTPUT

AS

DECLARE 
@c_ErrMsg VARCHAR(200)
, @c_ErrNum VARCHAR(5)
, @c_Continue INT
, @c_Date VARCHAR(20)


/* Assign value to local variables */
SET @c_Date = GETDATE()
SET @c_Continue = 0

/* Run Validations */
IF EXISTS (SELECT 1 FROM CONFIG(NOLOCK) WHERE cfg_key = @CFG_KEY)
    BEGIN
        SET @c_ErrNum = 60001
        SET @c_ErrMsg = 'Configuration Key (' + @CFG_KEY + ') already exist. Please check System Configuration. Error: ' + @c_ErrNum
        SET @CFG_MSG = @c_ErrMsg
        SET @c_Continue = 1
    END



/* Create Configuration */
SET @CFG_MSG = ''

IF @c_Continue = 0
    BEGIN
        IF NOT EXISTS(SELECT 1 FROM CONFIG(NOLOCK) WHERE cfg_key = @CFG_KEY)
            BEGIN
                INSERT INTO CONFIG
                    (
                        cfg_key         , cfg_short_value   , cfg_long_value    , cfg_desc          ,cfg_short_desc
                        , cfg_misc1     , cfg_misc2         , cfg_misc3         , cfg_misc4
                        , cfg_misc5     , cfg_add_who       , cfg_edit_date     , cfg_edit_who
                    )
                VALUES
                    (
                        @CFG_KEY        , @CFG_SHORTVALUE   , @CFG_LONGVALUE    , @CFG_DESC         , @CFG_SHORT_DESC
                        , @CFG_MISC1    , @CFG_MISC2        , @CFG_MISC3        , @CFG_MISC4
                        , @CFG_MISC5    , @CFG_USER         , @c_Date           , @CFG_USER
                    )

                SET @CFG_MSG = 'Configuration has been created.'            
            END
    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-06-17T02:44:59+00:00Added an answer on June 17, 2026 at 2:44 am

    Your stored procedure that returns the value has a parameter declared as OUTPUT, something like this:

    CREATE PROCEDURE my_returning_proc (@ret VARCHAR(10) OUTPUT) AS
    BEGIN .... END
    

    If you want to use this value you need to call the STORED PROCEDURE like this:

    DECLARE @var VARCHAR(10);
    EXEC my_returning_proc @var OUTPUT;
    PRINT @var
    

    The key’s here is to add OUTPUT into EXEC statement

    EDIT: Thanks for providing example.
    For your case you would call the stored procedure like this:

    DECLARE @var_returned VARCHAR(250);
    EXEC [dbo].[isp_CREATE_CONFIG] 'BLAH', 0, 'BLAH', 'BLAH', 'BLAH', ......, @var_returned OUTPUT
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a stored procedure which looks like this: BEGIN INSERT INTO result_table (SELECT
I have a stored procedure called WEB_SEL_SECURITY_QUESTIONS in my sql database which returns a
I have a datagridview and it is bound to a stored procedure which returns
I have a simple question regarding T-SQL. I have a stored procedure which calls
Helo, My question is I have one Stored Procedure in SQL Server that returns
I have Stored Procedure which returns Multiple tables as ResultSet. I Stored it in
I have a question about stored procedures in Oracle. Below is the stored procedure
This is two part question: I have two stored procedures: sp1 & sp2. If
A simple question about Stored Procedures. I have one stored procedure collecting a whole
I have a stored procedure that uses a table valued function which executes in

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.