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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T17:49:05+00:00 2026-05-21T17:49:05+00:00

I never have used SQL transactions, and in my case I know that I

  • 0

I never have used SQL transactions, and in my case I know that I really will have to use them. One of the features of my App, is to convert an Excel file to a Database.

So I get the values from the Excel, build an array of strings with the arguments (to be sent to the SP) and some of the values I will insert directly in the main table, and others I will insert in secondary tables, and then I will get id’s who will be in place of those values in the main table. What I am saying is that I have foreign keys, and it’s why I do this.

So I think I am doing this perfectly but without transactions. But if anything goes wrong when I am inserting the values in the tables I will have to do the rollback.

So in the process I am using 5 stored procedures, one for each table. These SP’s aren’t exclusive to this process. They will be used in the App to insert records.

But I need help in where to use transaction. Should I do it in C# (app side) or in SQL Server (server side)?

For now I am using the SqlTransaction object from C# and it works in some way, because if I do the rollback he really cancels all the inserts, but the ID’s that I have used in the transaction aren’t available anymore. Only if I drop all the tables and create them again will those ID’s be available again.

So I think that I am not using the transaction well and it’s why I need help, to know how and where is better to use the transaction.

  • 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-21T17:49:06+00:00Added an answer on May 21, 2026 at 5:49 pm

    I think you are on the right track with how you are using transactions, the issue is that the seed for IDENTITY columns is not rolled back.

    I’m guessing you are using MS SQL Server? To reset the IDENTITY columns without recreating the tables, you can use DBCC CHECKIDENT.

    DBCC CHECKIDENT (table_name, RESEED, 99);
    

    This would reset the seed so that the next identity value assigned would be 100. You of course have to record the highest identity value for the table prior to the BEGIN TRANSACTION.

    I would only use this if there is a single writer process. In a multiple writers situation, it is likely to make things go BOOM unless you do some serious table locking first. In the case of multiple writers I think you are much better off writing the rest o the code so “holes” in the identity column values are acceptable.

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

Sidebar

Related Questions

I have often heard this term being used, but I have never really understood
I'm used to doing Java programming, where you never really have to think about
I have a java web app that makes back-end use of a third-party web
I have never used triggers before in SQL server and I have looked around
I have used automation to insert values into a cell, however I have never
I have never used octal numbers in my code nor come across any code
i have never used LINQ in any of my projects , i have always
I have never used virtualization, and am trying to get up to speed. My
I've never used the Global Temporary Tables however I have some questions how they
I have never hand-coded object creation code for SQL Server and foreign key decleration

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.