Copy rows in the same table

  • Hi,

    I have table with columns (id, name, description,created_timestamp, created_userid, modified_timestamp, modified_userid, display_order, driver_type, application_id, formula)

    I am trying to copy rows from one application id to another application id in the same table but the thing is values in the some columns are different for example id,created_userid, modified_timestamp, modified_userid columns values are changed for each application id. there are columns with unique values for example name, description, application_id etc.

    Is there any way that I can achieve this (Copy all the rows including values from one application is to another but only unique values shoube copied but not the changing one like id and timestamps)?

    Thank you,

    Kind Regards,

    kk

  • Do you mean like this?

    --========== TEST DATA ==============

    declare @a as table

    (

    id int,

    name varchar(50),

    description varchar(50),

    created_timestamp datetime,

    created_userid char(3),

    modified_timestamp datetime,

    modified_userid char(3),

    display_order int,

    driver_type int,

    application_id int,

    formula varchar(50));

    insert into @a

    values

    (

    1,

    'Fred',

    'Worker',

    getdate(),

    'aaa',

    getdate(),

    'bbb',

    1,

    2,

    3,

    '2 * 2'

    );

    insert into @a

    values

    (

    2,

    'Jack',

    'Worker',

    getdate(),

    'aaa',

    getdate(),

    'bbb',

    4,

    5,

    7,

    '3/5'

    );

    select * from @a;

    --========= EXAMPLE ============

    insert into @a

    (

    name,

    [description],

    display_order,

    driver_type,

    application_id,

    formula

    )

    select

    name,

    [description],

    display_order,

    driver_type,

    application_id,

    formula

    from @a;

    select * from @a;

  • Not clear with the question that you ask...

    can you plzz attach a screenshot

    _______________________________________________________________
    To get quick answer follow this link:
    http://www.sqlservercentral.com/articles/Best+Practices/61537/

  • Not clear

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

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