A way to do this?

  • I am not sure how to do this. I need to run 3 sql statements against a table with a variable created in one of them.

    Here is the first statement

    Select ID from table1 where value = 1

    Need to store that value in a variable

    Update table1

    Set value = 0

    Where ID = variable

    Update table1

    Set value = 1

    Where ID = variable + 1

    ID is a incremental identity field, so it is numeric. Basically I need to change the value of one record to 0, and make the next records value = one.

    Any help is appreciated.

  • declare @variable int -- or whatever data type

    Select @variable = ID from table1 where value = 1

    Update table1

    Set value = 0

    Where ID = @variable

    Regards,

    Andras


    Andras Belokosztolszki, MCPD, PhD
    GoldenGate Software

  • What type of an SSIS object do I put the code into? Sorry I don't have much experience with this yet.

    Thanks

  • Murray - there's an IDENTITY field setting available to use for just this purpose. If you set this up - you don't need any special code to increment the ID number.

    Just go into design on the table you're looking at - you should see what I'm talking about.

    ----------------------------------------------------------------------------------
    Your lack of planning does not constitute an emergency on my part...unless you're my manager...or a director and above...or a really loud-spoken end-user..All right - what was my emergency again?

  • I already have it set up to increment, I just need to grab the next record in the table following the one I update.

  • Using an Execute SQL Task, set the Connection, Resultset to none, SQL Statement to the statement in my previous post, works. But you may have other requirements for this package.

    Andras


    Andras Belokosztolszki, MCPD, PhD
    GoldenGate Software

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

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