tanweer
tanweer

Reputation: 83

Deleting large amounts of data from SQL Server 2008

I have a scenario where I have to update in multiple tables, that are dependent to each other e.g has relationship, with large data from a web page, where lot of textboxes, checkboxes and dropdownlists are there.

I am using jQuery.ajax to save the data. New data save method is written there and it is working.

Now it is very difficult to handle large amount of data for update purpose.

I have an idea that I will delete all data and save it as new row. Is this a good idea or not?

What should I have to do here remembering updating all these records I have to spend a week to write an Update method.

Please guide me in this scenario.

Upvotes: 2

Views: 367

Answers (1)

Pondlife
Pondlife

Reputation: 16260

Your question is quite vague, but I think you're saying this:

  • I can INSERT data into my database
  • UPDATEing my data looks difficult, so I would prefer to just DELETE and then INSERT again (because I've already written that code)

I would say that this is a bad idea, for the following reasons (and no doubt many more):

  • Even if you just DELETE, you still need to identify the correct rows to delete, delete from tables in the correct order etc. So it's unlikely you will save much time anyway
  • You will add unnecessary complexity and extra maintenance work to the application: transaction handling, additional code to maintain, permissions changes etc.
  • Adding server-side logic to the database in the form of triggers and/or procedures will become more difficult because a DELETE does not necessarily really mean DELETE any more, it might mean the start of an UPDATE (I mean logically, not physically) and that is a huge pain to maintain as well as potentially breaking any code, traces or audits that are based around DML actions or events
  • The database will need to do more logging because you have divided one operation into two

Perhaps you have good reasons for wanting to avoid an UPDATE, but "it's difficult to write" shouldn't be one of them (apologies if I'm oversimplifying your situation).

You may get a more useful answer if you explain exactly what is "difficult", give some background about what a "large amount of data" means, show some table structures and code that illustrate your difficulties etc.

Upvotes: 2

Related Questions