Results 1 to 2 of 2
  1. #1
    Join Date
    Oct 2004

    Unanswered: Insert based on query

    Hi everyone -

    I have a simple query that will return a result set that
    has a unique value in it (primary key) -

    I would like to cycle through each of these values
    returned from the query, and create a new row
    in another table.

    I do not want to use a cursor -

    The first query is pretty simple....

    select p_id from table1 where active=0

    the query i need to execute for each of the p_id that
    is returned in the first example is....

    insert into table2 (p_id_field, text_field) values (@p_id, 'text')

    the @p_id is filled in from the primary query...

    please advise


  2. #2
    Join Date
    Feb 2004
    In front of the computer
    Provided Answers: 54
    Example G


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts