c# - Comparing values of rows...row by row? -


i have small query joins temp tables such

select u.batch_uid, u.user_id, u.firstname, u.middlename, u.lastname, u.email, u.student_id, u.row_status, uff.batch_uid, uff.user_id, uff.firstname,uff.middlename,uff.lastname,uff.email, uff.student_id,uff.row_status users u full outer join users_feed_file uff on u.user_id = uff.user_id u.data_src_pk1 = 83 

the results example this:

(users u) batch_uid user_name row_status (users_feed_file uff) batch_uid user_name row_status             johndoe   johndoe            2                           johndoe   johndoe            0 

because, first 3 columns come source table being replicated live table. last 3 columns come feed file gets processed , inserted temp table , dropped after run time completed(and re-loaded later new data).

what i'm trying accomplish looking @ rows perform various operations. i'm going checking 25,000 rows. in case, i'd check like

if u.batch_uid, u.user_name, u.row_status not null , uff.uid, uff.user_name, uff.row_status not null , u.row_status equal 2 , uff.row_status equal 0 add user feed file enable him 

however these(and other kinds of conditions , checks)need done against 25k rows returned , processed in c# row row determine if code needs insert line file or not.

thank you.

you have couple of different issues address in question.

first, in initial select you're using full outer join--but you're explicitly looking records 3 fields in (table) user match 3 fields in (table) userfeed. see dramatically better performance--and process lot fewer records--with inner join, this:

select u.batch_uid, u.user_id, u.firstname,  u.middlename, u.lastname, u.email, u.student_id,  u.row_status, uff.batch_uid, uff.user_id, uff.firstname,  uff.middlename, uff.lastname, uff.email, uff.student_id,  uff.row_status users u  inner join users_feed_file uff  on u.user_id = uff.user_id u.data_src_pk1 = 83 , u.row_status = 2 , uff.row_status = 0; 

that give rows match complete condition--it should relatively small set of rows.

but--if you're retrieving records (table) user compare (table) userfeedfile, why user's name, address, etc.? no need--just data want:

select u.user_id user u inner join userfeedfile uff on u.user_id = uff.user_id u.row_status = 2 , uff.row_status = 0 , u.data_src_pkt1 = @packetnumber;   -- that's parameter 

the next question is: going rows? if you're going update field value in table (or, perhaps, in user feed file table) can insert or update statement. update (table) userfeedfile, this:

update userfeedfile set enabled = 1 user u inner join userfeedfile uff on u.user_id = uff.user_id u.row_status = 2 , uff.row_status = 0 , u.data_src_pkt1 = @packetnumber; 

(you can change second line, set statement, update field or fields choose.)

as general rule, sql databases work best on sets of data. if find iterating on data set row @ time, , if going surface data different process (potentially across network on difference machine) handle row in .net code, stop , think of how within sql server, using sets. performance difference dramatic.


Comments

Popular posts from this blog

c++ - OpenCV Error: Assertion failed <scn == 3 ::scn == 4> in unknown function, -

php - render data via PDO::FETCH_FUNC vs loop -

The canvas has been tainted by cross-origin data in chrome only -