Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Ways to avoid Transaction Locks

Author  Topic 

dasharath.yadav
Starting Member

2 Posts

Posted - 2009-01-20 : 08:11:36
Hi ,

I am an ASP.net Developer , i am working on a Software that has a SaaS Module. In our software there are lots of instance where i need to insert multiple records into database. While inserting data into database i wanted to know, how can I increase the performace/ integrity of my appplication when then are multiple insert into database.


1. I am Processing all the data Initially and then using transaction to insert data.
2. I can pass all the data to 1 store procedure and in the store procedure i can have the transaction that will loop all the data and inset it into database.

Please help me which is the better option or is there any option better then this.

awaiting reply.




harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2009-01-20 : 08:19:35
Normally, transactions are useful only when you data manipulation spans across different related tables. But in your case, you are inserting only in single table.

One approach would be that you can load all the data in a staging table where you can do all the processing part. Once the final data set is ready, you can just copy all those records in one single insert to the final table.



Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

ayamas
Aged Yak Warrior

552 Posts

Posted - 2009-01-20 : 08:20:12
The way I will do it is I will create a data to be inserted in a XML format using an XMLwritter which will go as parameter to the SP as text data type.After that by using the system SP sp_xml_preparedocument and OPENXML the data can be inserted into the table.
Go to Top of Page

dasharath.yadav
Starting Member

2 Posts

Posted - 2009-01-20 : 08:31:11
Actually i have more then 2 tables for e.g. Suppose there are 3 tables
Product
Package
Package Link

A Package can contain multiple Products, so in package table i store package header and in PackageLink i store all the products that a package contains.

There are cases when a two users are updating some Package or inserting new package, due to which there is a chance of locks.

how can i avoid this locks



Go to Top of Page
   

- Advertisement -