1. From the database in the first query to meet the criteria of records, stored in a DataTable, in the use of C # and so began to traverse the table, using the primary key in DataRow, and then read the corresponding criteria for the number of records, merged these second read to the record content, Return to the previous DataRow data row. There is nothing wrong with this, but if the volume of data is large, we may face countless open disconnected database links, the speed efficiency will be very low.
2. Read data from the database to a table and return to the UI layer. Everyone wants to do this, but it used to be stupid not to study this, because today, because of the large amount of data, I have to think of some other ways to improve efficiency.
GOOGLE~HK, if there is an answer, and then according to gourd painting gourd, himself wrote a
The goal is to obtain a non quantitative, qualifying part-time record and record each part of the project in a few fields, and then return to table one at a time
Copy Code code as follows:
Create function fn_getjoblistbypid--creates custom functions to obtain all project numbers and number of items assigned to part-time participation
(
@ParttimerID int
)
Returns @t table (Jobs varchar (5000), Parttimerid int,totalcount int)
As
Begin
DECLARE @sql varchar (5000), @TotalCount int
Set @sql = '
Set @TotalCount =0
Select @sql = @sql +j.jobno+ '-' +j.jobwave+ ', @TotalCount = @TotalCount +1
From Onjb_jobapplication A,onjb_jobs J
where a.parttimerid= @ParttimerID
and a.result= ' V '
and A.jobid=j.jobid
Insert @t values (@sql, @ParttimerID, @TotalCount)
Return
End
Reference
Copy Code code as follows:
--...........................
--Done project
LEFT join (select Jobs,parttimerid,totalcount from Fn_getjoblistbypid (@ParttimerID)) as J1
on P.par Ttimerid=j1. Parttimerid
--In doing project
LEFT join (select Curjobs,parttimerid,curcount from Fn_getcurjobsbypid (@ParttimerID)) as J2
on P.parttimerid=j2. Parttimerid
where p.parttimerid= @ParttimerID