Stored Procedure to Copy from 1 table to another

  • I have in one table the following:

    TABLE A

    SessionID, QuizID, QuestionID, AnswerID, Answer

    And I want an SP to transfer from this table to Table B with the following structure:

    TABLE B

    UniqueID (which I get somewhere else),QuestionID, ColumnID (AnswerID), Answer

    So there are 3 columns the same, so i want to transfer where the sessionID is X into

     

    Any help would be appreciated

    Darryl Wilson
    darrylw99@hotmail.com

  • INSERT INTO...SELECT... should help

    --
    Frank Kalis
    Microsoft SQL Server MVP
    Webmaster: http://www.insidesql.org/blogs
    My blog: http://www.insidesql.org/blogs/frankkalis/[/url]

  • CREATE PROCEDURE usp_copy_session

        @SessionID int,

        @UniqueID int

    AS

    INSERT INTO

    (UniqueID, QuestionID, ColumnID, Answer)

    SELECT @UniqueID, QuestionID, AnswerID, Answer

    FROM

    WHERE SessionID = @SessionID

    Far away is close at hand in the images of elsewhere.
    Anon.

  • --
    Frank Kalis
    Microsoft SQL Server MVP
    Webmaster: http://www.insidesql.org/blogs
    My blog: http://www.insidesql.org/blogs/frankkalis/[/url]

Viewing 4 posts - 1 through 3 (of 3 total)

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