I uploaded the csv file to a dummy table (csv_upload) in sql server 2008. I have to distribute the data in the tables below using a trigger;
Questions Answers Test QAT --------- --------- ------ ----- Questid Ansid Testid Questid Question Answers Testname Ansid Testid id StdUsername
Launch code;
INSERT INTO tbl_answers ( Answer) select DISTINCT Answer from tbl_csv_upload INSERT INTO tbl_questions ( Question ) select DISTINCT Question from tbl_csv_upload INSERT INTO tbl_taqa (StdUsername,questid, ansid , testid ) SELECT StdUsername ,q.quest_id,a.ans_id,t.test_id FROM csv_upload c, questions q, answers a, test t WHERE c.Question = q.Question AND c.Answer = a.Answer AND t.test_id = IDENT_CURRENT('test')
This trigger worked well for the first boot from the asp.net application, but on the second boot it saves the data 4 times in the QAT table instead of some, but the other tables are in order. I need urgent help.
source share