This is not tested, but should be close to what you are looking for. I know I'm a loser, but the only thing I could think of right off used a cursor. Someone please post a nice set based solution. create procedure CopyQuestion@idtocopy intASdeclare @tempquestioniddeclare @tempquestiontextiddeclare @questiontextidinsert into question (name) select name from question where id = @idtocopyselect @tempquestionid = @@identitydeclare question_cursor cursor for select id from [question text] where id = @idtocopyopen question_cursorfetch next from question_cursor into @questiontextidwhile @@fetch_status = 0begin insert into [question text] (questionid, text) select @tempquestionid, text from [question text] where id = @questiontextid select @tempquestiontextid = @@identity insert into [options] (questiontextid, text) select @tempquestiontextid, text from [options] where questiontextid = @questiontextid fetch next from question_cursor into @questiontextidendclose question_cursordeallocate question_cursor
Jeff BanschbachConsultant, MCDBAEdited by - efelito on 06/18/2002 10:18:41