Count SQL statement in script task

  • Hi friends

    I am trying to write vb.net script in SSIS script task for the following logic.

    while ( select count(*) from table1) > 0

    insertsql = "insert into table1 (col1,col2)values Select col1,col2 from table2"

    SqlHelper.ExecuteNonQuery(connectionString, CommandType.Text, insertsql)

    End While

    insert statement works perfect. How do I write the count sql statement in while ?

    AM

  • selectsql = "select count(*) from table1"

    SqlHelper.ExecuteScalar(connectionString, CommandType.Text, selectsql)

    While (SqlHelper.ExecuteScalar(connectionString, CommandType.Text, selectsql) > 0

    How could I change this script to make it works?

    Thanks for help.

  • I found a way to make it works. I have to close this question.

  • ayemya (10/13/2008)


    I found a way to make it works. I have to close this question.

    You should continue the question because you're still using a loop and a function to do this. 😉

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • Jeff Moden (10/13/2008)


    ayemya (10/13/2008)


    I found a way to make it works. I have to close this question.

    You should continue the question because you're still using a loop and a function to do this. 😉

    I'd imagine he'll be back... with the "my machine is smoking because that thing is processing FOREVER"....:) That's a funny thing that happens when you use a WHILE clause with no exit strategy.....:cool:

    ----------------------------------------------------------------------------------
    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?

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

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