How to insert multiple rows with a single INSERT.

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Tuhin Kumar

    How to insert multiple rows with a single INSERT.

    Hi,
    I would like to know how to insert multiple rows into a table, using a
    single INSERT statement. My requirement is like this I have a table ABC
    which contains multiple employees entries with empId as the primary key.
    Now I want to insert the all the empid multiplied by X and y (<EMPID>*x*y)
    into a table DEF plus filling other columns for each employee rows.

    Table ABC
    ---------
    EMPID QQQ LLL MMM
    1 5 "L" 20
    4 45 "J" 43
    6 63 "Q" 89

    The table DEF need to be populated from ABC as below
    Table DEF
    ---------
    EMPIDMOD KKK MMM
    1*X*Y 0 786
    4*X*Y 0 786
    6*X*Y 0 786


    Thanks,
    Tuhin
  • Ievel

    #2
    Re: How to insert multiple rows with a single INSERT.


    "Tuhin Kumar" <tkumar@ipolicy net.comwrote in message
    news:e4ad76f5.0 307140435.388f3 6ca@posting.goo gle.com...
    Hi,
    I would like to know how to insert multiple rows into a table, using a
    single INSERT statement. My requirement is like this I have a table ABC
    which contains multiple employees entries with empId as the primary key.
    Now I want to insert the all the empid multiplied by X and y (<EMPID>*x*y)
    into a table DEF plus filling other columns for each employee rows.
    >
    Table ABC
    ---------
    EMPID QQQ LLL MMM
    1 5 "L" 20
    4 45 "J" 43
    6 63 "Q" 89
    >
    The table DEF need to be populated from ABC as below
    Table DEF
    ---------
    EMPIDMOD KKK MMM
    1*X*Y 0 786
    4*X*Y 0 786
    6*X*Y 0 786
    >
    >
    Thanks,
    Tuhin
    Insert into DEF
    (EMPID
    ,MOD
    ,KKK)
    SELECT EMPID*x*y
    , 0
    , 786
    FROM ABC;

    ieVel


    Comment

    Working...