script

  • Hi,

    In my table pp table is there.pp table having isactive field .
    if i set isactive = 0 in pp table  it will exports table records pp to  pp_old  table  and after wards the pp table needs to Truncated
    any scripts please above logic

  • Diyas - Tuesday, July 10, 2018 1:28 PM

    Hi,

    In my table pp table is there.pp table having isactive field .
    if i set isactive = 0 in pp table  it will exports table records pp to  pp_old  table  and after wards the pp table needs to Truncated
    any scripts please above logic

    With > 4000 points, you should know better. Please post DDL, sample data and desired results

    If you haven't even tried to resolve your issue, please don't expect the hard-working volunteers here to waste their time providing links to answers which you could easily have found yourself.

  • pp source table -->select id,PPID,Name,Create_Date,Modified_Date, isactive from A.PP
    pp_old destination table.--> select id,PPID,Name,Create_Date,Modified_Date, isactive from A.PP_old

  • Diyas - Tuesday, July 10, 2018 2:10 PM

    pp source table -->select id,PPID,Name,Create_Date,Modified_Date, isactive from A.PP
    pp_old destination table.--> select id,PPID,Name,Create_Date,Modified_Date, isactive from A.PP_old

    With > 4000 points, you should know better.  This does not qualify as DDL, sample data, or expected results.  We don't have access to your database, so providing a query that can only be run against your database is pointless.

    Drew

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • Okay, let us just throw out a wild a$$ guess:

    declare @DeletedRec table (id int);

    insert into A.PP_OLD
    output inserted.id into @DeletedRec(id)
    select * from A.PP where isactive = 0;

    delete from A.PP [pp] where [pp].[id] in (select id from @DeletedRec);

    -- or, you could just do this:

    delete from A.PP where isactive = 0;

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

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