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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T02:18:48+00:00 2026-05-30T02:18:48+00:00

I have 2 stored procedures: up_proc1 and up_proc2. This is (a simplified version of)

  • 0

I have 2 stored procedures: up_proc1 and up_proc2.

This is (a simplified version of) up_proc2:

CREATE PROCEDURE dbo.up_proc2 
    @id_campaign uniqueidentifier, @id_subcampaign uniqueidentifier, 
    @id_lead uniqueidentifier, @offer NVARCHAR(1000) = NULL
AS  
   SET NOCOUNT ON

   DECLARE @id UNIQUEIDENTIFIER

   SELECT @id = id FROM prospects WHERE id_lead = @id_lead 
        AND id_campaign = @id_campaign AND id_subcampaign = @id_subcampaign
   IF @id IS NULL
   BEGIN
           SET @id = newid ()
           INSERT INTO prospects (id, id_campaign, id_subcampaign, id_lead, offer) 
             values (@id, @id_campaign, @id_subcampaign, @id_lead, @offer)
   END
   ELSE
   BEGIN
           UPDATE prospects set offer = @offer WHERE id=@id
   END

   SELECT @id AS ID
GO

From up_proc1 I call up_proc2. What I would like to achieve is to store the @id of up_proc2 in a variable declared in up_proc1. Is this possible without using an output parameter?

This is how up_proc1 looks like:

CREATE PROCEDURE dbo.up_proc1
AS  
   SET NOCOUNT ON

   DECLARE @fromProc2 UNIQUEIDENTIFIER

   -- NOT WORKING
   -- select @fromProc2 = exec up_insertProspects [snip]

   -- ALSO NOT WORKING
   -- exec @fromProc2 = up_insertProspects [snip]
  • 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-30T02:18:49+00:00Added an answer on May 30, 2026 at 2:18 am

    What you could do is store the output into a table variable:

    DECLARE @tmpTable TABLE (ID UNIQUEIDENTIFIER)
    
    INSERT INTO @tmpTable
       EXEC dbo.up_proc2 ..........
    

    and then go from there and use that table variable later on.

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

Sidebar

Related Questions

I have two stored procedures I wish to use in my stored procedure, but
I have a stored procedure that basically calls 7 or 8 other stored procedures.
I have a stored procedure in SQL server that looks something like this: insert
Workflow: I have two stored procedures. One stored procedure calls the other. When I
I have stored procedures in SQL Server T-SQL that are called from .NET within
I still have loads to learn. At the moment I have stored procedures, and
I have several Stored Procedures that when added to my dbml, it seems that
I have some complex stored procedures that may return many thousands of rows, and
We have lots of stored procedures which all contain a lot of comments. Is
I have group of stored procedures with names like 'somename_%'. Are there any way

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.