Clone MS SQL Server Data across multiple sub tables

I have a set of data that I need to clone from three cascading tables
tblSurvey has SurveyID, SurveyName   (UID is SurveyID)
tblQuestions has QuestionID, QuestionText, SurveyID   (UID is QuestionID)
tblAnswers has  AnswerID, AnswerText,QuestionID  (UID is AnswerID)

I insert into tblSurvey (Select SurveyName from tblSurvey where SurveyID = @OldSurveyID)
I insert into tblQuestions (Select QuestionText,@NewSurveyID from tblQuestions where SurveyID = @OldSurveyID)

My problem is matching inserting the AnswerText and matching to the new set of QuestionID's
Larry Bristersr. DeveloperAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

lcohanDatabase AnalystCommented:
The link between tblQuestions  and tblAnswers  is the QuestionID  so a statement like below will show you all related data between the 3 tables:

Select s.SurveyId, s.SurveyName, q.QuestionID, q.QuestionText, a.AnswerId, a.AnswerText
from tblQuestions q, tblAnswers  a, tblSurvey s
where q.QuestionID = a.QuestionID and q.SurveyId = s.SurveyId

All left now is to match the AnswerText  "via" the QuestionId to the @NewSurveyID

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Larry Bristersr. DeveloperAuthor Commented:
I'll review when I am back at my desk in the morning
Larry Bristersr. DeveloperAuthor Commented:
Very sorry for the late getback

I have been traveling
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server 2008

From novice to tech pro — start learning today.