Click here to Skip to main content
15,888,199 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I want to fetch data from historical tables of SQL server database. Currently I am having a set of minimum 20 queries and each query contains "Union All" of 10 queries. It will take almost a half hour (30 minutes) to execute all 20 queries sequentially. Again, if I use thread, then all queries get fired with in few time span and due to this sometimes database gets locked as there are 20 connections are open at a time.

Is there any better way to do this, stuck with this issue so many times?

What I have tried:

Use Thread , but creates deadlock situation.
Posted
Updated 19-Mar-16 7:05am
Comments
CHill60 19-Mar-16 10:16am    
Perhaps if you shared your queries we could assess them for performance
[no name] 19-Mar-16 10:58am    
Share relevant code which takes time..
RickZeeland 25-Mar-16 14:07pm    
And ? have you fallen asleep ? did you try any of the suggestions ?

You might try the BCP utility, which is meant to copy large amounts of data.
This can be executed from the command prompt, example:

C#
bcp "SELECT Name FROM AdventureWorks2008R2.Sales.Currency" queryout Currency.Name.dat -T -c


More information: bcp Utility[^]
 
Share this answer
 
U said you used Thread. Did you try to use PLINQ?

A case like that is a candidate for data partitioning. We could partition the 20 queries in 20 parallel executions with a defined parallelism degree.

It would help if we knew about the queries.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900