Help w/ proc sql

  • I have a procedure in which I'm trying to update some tables with insert statements. One of those tables has many columns. Is there an easy way to do this without having to declare a bunch of variables? Basically what I want to do is take all of the data from an existing row and create a new row with that same data - except for a few columns.

    For example:

    TABLE_A - currently

    col_a...col_b...col_c...col_d...col_e...change_col..revision_no

    A.........B........C.........D........E..........AA................1

    TABLE_A - what I want

    col_a...col_b...col_c...col_d...col_e...change_col..revision_no

    A.........B........C.........D........E..........AA................1

    A.........B........C.........D........E..........BB.................2

    I don't want to have to: Select @col_a = col_a,@col_b = col_b,@col_c = col_c... if I can help it.

     

  • Put literals in the embedded select use to insert

    INSERT INTO table_a ( col_a, col_b, ...)

       SELECT col_a, col_b, col_c..., 2 as revision_no

           FROM table_a

       WHERE key = ...

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

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