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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T08:14:26+00:00 2026-06-08T08:14:26+00:00

I have two tables. dbo.Emp EmpID(PK) | Name | TypeID(FK) dbo.EmpType TypeID(PK) | Type

  • 0

I have two tables.
dbo.Emp
EmpID(PK) | Name | TypeID(FK)

dbo.EmpType
TypeID(PK) | Type

TypeID: AutoIncrement only in dbo.EmpType

When I update value for TypeID in Emptype, it needs get stored in TypeID of dbo.Emp
I used SP which is not working.

Create Procedure bridge_Type(
@EmpID INT,
@Name   varchar(50),
@Mob2   numeric(10,0),
@Email  varchar(50),
@Type   varchar(50)
)
AS 
DECLARE @TYPEID int
Set NOCOUNT OFF

BEGIN TRANSACTION
Insert into dbo.Emp VALUES (@EmpID, @Name, @Mob2, @Email, @TYPEID)
IF @@ERROR <> 0
BEGIN 
ROLLBACK
RETURN
END

INSERT INTO dbo.EmpType VALUES (@Type)
IF @@ERROR <> 0 
BEGIN     
ROLLBACK     
RETURN 
END  

declare @id int
SET @id= @TYPEID;
Update Dbo.Emp 
Set @TYPEID= (Select TypeID from dbo.EmpType
          WHERE  TypeID=@typeID)
COMMIT 
  • 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-08T08:14:27+00:00Added an answer on June 8, 2026 at 8:14 am

    Try This SP, This will first insert the EmpType, and From SCOPE_IDENTITY() it will get the Inserted Identity Value, and then insert emp.

    Create Procedure bridge_Type(
    @EmpID INT,
    @Name   varchar(50),
    @Mob2   numeric(10,0),
    @Email  varchar(50),
    @Type   varchar(50)
    )
    AS 
    DECLARE @TYPEID int
    Set NOCOUNT OFF
    
    BEGIN TRANSACTION
    
    INSERT INTO dbo.EmpType VALUES (@Type)
    
    SET @TYPEID = SCOPE_IDENTITY()
    
    IF @@ERROR <> 0 
    BEGIN     
    ROLLBACK     
    RETURN 
    END 
    
    
    Insert into dbo.Emp VALUES (@EmpID, @Name, @Mob2, @Email, @TYPEID)
    IF @@ERROR <> 0
    BEGIN 
    ROLLBACK
    RETURN
    END
    
    COMMIT 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So here's the setup. I have two tables: CREATE TABLE dbo.TmpFeesToRules1(Name varchar, LookupId int)
I have two tables: CREATE TABLE dbo.country ( cntry_id VARCHAR(2) NOT NULL, name VARCHAR(50)
I have two tables like, CREATE TABLE [dbo].[entry] ( [id] [int] NULL, [service] [int]
I have two tables one with ID and NAME table 1 ID | NAME
I have two tables user table user_id | name | 1 | peter |
I have two tables: CREATE TABLE InmarsatZenith.dbo.ClientJob (JobRef int PRIMARY KEY NOT NULL, IntRef
i have two tables: 1. CREATE TABLE [dbo].[HotelSourceMap]( [hotelsourcemapid] [bigint] IDENTITY(1,1) NOT NULL, [dspartnerid]
I have two tables: CREATE TABLE [dbo].[Context] ( [Identity] int IDENTITY (1, 1) NOT
I have two tables - let's call them dbo.ValuesToReduce and dbo.Reserve The data in
I have two tables called Reviews and Levels. CREATE TABLE [dbo].[Reviews]( [ReviewID] [int] IDENTITY(1,1)

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.