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

  • Home
  • SEARCH
  • 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 6943623
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T13:10:49+00:00 2026-05-27T13:10:49+00:00

I am having a scenario where I have to insert some master data into

  • 0

I am having a scenario where I have to insert some master data into the table with script, so that we can this script on production server while deployment.

My tables are

Category
 --Id (PK, Identity)
 --Name

CategoryType
  --Id (PK, Identity)
  --Name
  --CategoryID (FK) 

Now I have some row data in excel for category and categorytype.
I have to generate the data script (bunch of insert statement).

What I did

Start with  identity_insert ON 
insert statement for Category table
Insert statement for CategoryType table with respect of category PK
end  identity_insert Off

I just want to know Is there any way I can avoid identity_insert ON/OFF thing.

  • 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-27T13:10:50+00:00Added an answer on May 27, 2026 at 1:10 pm

    may be this is what you are looking for:

    DECLARE @inserted table ( id int ) --assuming ID is int
    
    INSERT INTO Category ( Name )
    OUTPUT INSERTED.Id INTO @inserted
    VALUES( 'MyCategory Name' )
    
    INSERT INTO CategoryType( Name, CategoryID )
    SELECT id, 'MyCategoryTypeName'
    FROM @inserted
    

    Hope it helps
    Best Regards,

    Iordan

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

Sidebar

Related Questions

How would you test this scenario? I've just started looking into NHibernate and having
Hi i am having problem inserting data into multiple table from one view. First
I have a scenario that looks like this: User A is a registered user.
I am having a scenario, in which i have multiple delegates attached to the
Scenario Having already read a post on this on the same site, which didn't
Having some trouble with what should be a very simple scenario. For example purposes,
Take this scenario: You have a few flag enumerations in C# tied to (and
Scenario: I have the following structure; Group (parent) -> Item (child). A Group can
I am having a scenario where there are several subclasses which have got similar
Here's the scenario I have a page lets say login.aspx having a button called

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.