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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T11:23:22+00:00 2026-06-10T11:23:22+00:00

I have an insert stored procedure with incremented Id ( int ). I’ll like

  • 0

I have an insert stored procedure with incremented Id (int). I’ll like to take that Id and insert it to another table and also one of variable from the insert stored procedure.

I know you can do select from inserted but if I’m not mistaking that allowed you to select values from the inserted row.

Is there anyway to persevere the variable after executed the stored procedure and pass it to trigger?

Edit: sorry, let me included the stored procedure that I’m using. Table foo have a Id that is auto incremented and I want a trigger to insert the foo’s Id and the @mid to another table after this stored procedure is run. However as you can see that @mid is not being insert to table foo.

 ALTER PROCEDURE [dbo].[foo]
    @userName varchar(50),
    @somefoo varbinary(max),
    @mid int
AS
BEGIN
    SET NOCOUNT ON;

    INSERT INTO fooTable(UserName, SomeFoo)
    VALUES (@userName, @somefoo);

END
  • 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-10T11:23:24+00:00Added an answer on June 10, 2026 at 11:23 am

    The inserted pseudo-table allows you to select the value that is now in the table. The deleted pseudo-table allows you to select the value that used to be in the table before the insert happened. Since you say insert proc i am assuming it’s not an insert/update proc. I am not clear on what you want to do. You want the trigger to copy the identity field and one other column? Easy. You want the trigger to copy the identity field and a proc parameter that is not actually stored in the table? Impossible – but if that’s what you want, then you can do it in the proc instead.

    1) Trigger:

    Insert into foo (a, b)
    select my_identity, some_column
    from inserted
    

    2) Proc:

        ..do main insert...
        insert into foo (a, b)
        select scope_identity(), @some_parameter
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

HI, I have an insert statement in a Stored Procedure that requires the value
I have just written a stored procedure and stored function that serve to insert
I have a stored procedure that inserts a user into a table but I
I'm using devexpress and i have two problems. My insert stored procedure work fine.
I have a stored procedure with multiple insert/select statements. Let's say I'm using the
I have a stored procedure which is called inside a trigger on Insert/Update/Delete. The
Say I have a stored procedure consisting of several separate SELECT, INSERT, UPDATE and
I have a stored procedure that does, among other stuff, some inserts in different
Suppose you have the following... An ASP.NET web application that calls a stored procedure
I have the following stored procedure: ALTER PROCEDURE Pro_members_Insert @id int outPut, @LoginName nvarchar(50),

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.