inserting to primary table and secondary table at the same time

  • Hi All,

    Assessments (assessmentid identity(1,1), title varchar(100),sectionid int,maxpoints decimal)

    SLOAssessments(assessmentid int,sloid int ,weight)

    Note assessmentid,sloid is a composite primary key

    I am importing all assessments of section 1 to section2 and also there corresponding records for sloassessments

    Example

    Assessments:

    1,1,introduction,100

    2,1,chapter1, 100

    3,1,chapter3, 100

    Sloassessments

    1,1,40

    2,1,60

    2,1,30,

    2,1,70

    SLO student learning outcomes

    What is the best way to do it without using cursors

    Thanks

  • It's a rather vague description o what you're trying to do. So the answer will be vague, too:

    You could use the OUTPUT clause together with the first statement to capture the assessmentid values of the inserted values. Use either this table variable - or copy the data into an indexed temp table if the number of inserted rows is rather large - and join it to when inserting the data into the second table. For details how to use the OUTPUT clause, please see BOL.



    Lutz
    A pessimist is an optimist with experience.

    How to get fast answers to your question[/url]
    How to post performance related questions[/url]
    Links for Tally Table [/url] , Cross Tabs [/url] and Dynamic Cross Tabs [/url], Delimited Split Function[/url]

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply