insert into #variables.tableprefix#answers(id, questionidfk, answer, rank) values(, , , ) select id from #variables.tableprefix#questions where rank = and surveyidfk = insert into #variables.tableprefix#questions(id, question, rank, required, surveyidfk, questiontypeidfk) values( , , , , , ) delete from #variables.tableprefix#answers where id = delete from #variables.tableprefix#results where answeridfk = delete from #variables.tableprefix#answers where questionidfk = delete from #variables.tableprefix#questions where id = delete from #variables.tableprefix#results where questionidfk = select id, answer, rank from #variables.tableprefix#answers where questionidfk = order by rank asc select #variables.tableprefix#questions.id, surveyidfk, question, questiontypeidfk, rank, required, #variables.tableprefix#questiontypes.name as questiontype from #variables.tableprefix#questions, #variables.tableprefix#questiontypes where #variables.tableprefix#questions.id = and #variables.tableprefix#questions.questiontypeidfk = #variables.tableprefix#questiontypes.id select rank from #variables.tableprefix#questions where surveyidfk = order by rank asc select #variables.tableprefix#questions.id, surveyidfk, question, questiontypeidfk, rank, required, #variables.tableprefix#questiontypes.name as questiontype, #variables.tableprefix#questiontypes.handlerroot as handlerroot from #variables.tableprefix#questions, #variables.tableprefix#questiontypes where surveyidfk = and #variables.tableprefix#questions.questiontypeidfk = #variables.tableprefix#questiontypes.id and #variables.tableprefix#questions.rank = order by rank asc update #variables.tableprefix#answers set answer = , rank = where id = insert into #variables.tableprefix#answers(id,questionidfk,answer,rank) values(, , , ) select id from #variables.tableprefix#questions where rank = and id <> and surveyidfk = update #variables.tableprefix#questions set question = , rank = , required = , surveyidfk = , questionTypeidfk = where id =