Quick and easy copy of a Row to another Row

Discussion in 'ASP .Net' started by Luis Esteban Valencia, Jan 6, 2005.

  1. How would I quickly read several records (rows) from a SQL table, change the
    key in each (recordid) and insert them back into the same table thus
    creating duplicates.

    I'm reading the rows like this:

    Dim strSQL As String = _
    "SELECT * FROM XMMProjDet " & _
    "WHERE Project = '" & Trim(txtProject.Text) & "' and
    ProposalNbr = " & Trim(txtCopyFrom.Text)

    Dim scnnSol As New SqlConnection(SQL_CONNECTION_STRING)
    Dim scmd As New SqlCommand(strSQL, scnnSol)
    scnnSol.Open()
    Dim myReader As SqlDataReader = scmd.ExecuteReader()

    Thanks much.


    --
    LUIS ESTEBAN VALENCIA
    MICROSOFT DCE 3.
    MIEMBRO ACTIVO DE ALIANZADEV
    http://spaces.msn.com/members/extremed/
    Luis Esteban Valencia, Jan 6, 2005
    #1
    1. Advertising

  2. Luis Esteban Valencia

    Curt_C [MVP] Guest

    Select into

    --
    Curt Christianson
    Site: http://www.Darkfalz.com
    Blog: http://blog.Darkfalz.com


    "Luis Esteban Valencia" <> wrote in message
    news:...
    > How would I quickly read several records (rows) from a SQL table, change
    > the
    > key in each (recordid) and insert them back into the same table thus
    > creating duplicates.
    >
    > I'm reading the rows like this:
    >
    > Dim strSQL As String = _
    > "SELECT * FROM XMMProjDet " & _
    > "WHERE Project = '" & Trim(txtProject.Text) & "' and
    > ProposalNbr = " & Trim(txtCopyFrom.Text)
    >
    > Dim scnnSol As New SqlConnection(SQL_CONNECTION_STRING)
    > Dim scmd As New SqlCommand(strSQL, scnnSol)
    > scnnSol.Open()
    > Dim myReader As SqlDataReader = scmd.ExecuteReader()
    >
    > Thanks much.
    >
    >
    > --
    > LUIS ESTEBAN VALENCIA
    > MICROSOFT DCE 3.
    > MIEMBRO ACTIVO DE ALIANZADEV
    > http://spaces.msn.com/members/extremed/
    >
    >
    Curt_C [MVP], Jan 6, 2005
    #2
    1. Advertising

  3. Yes, this would work BUT the recordid would be duplicated. I need to be
    able to change just one or two fields in each record as they are copied.
    I'm trying to avoid reading the row and copying ALL the values out to
    individual vars (there are a lot of columns), change the two vars that I
    need and then insert them into the table

    --
    LUIS ESTEBAN VALENCIA
    MICROSOFT DCE 3.
    MIEMBRO ACTIVO DE ALIANZADEV
    http://spaces.msn.com/members/extremed/
    "Curt_C [MVP]" <software_AT_darkfalz.com> escribió en el mensaje
    news:...
    > Select into
    >
    > --
    > Curt Christianson
    > Site: http://www.Darkfalz.com
    > Blog: http://blog.Darkfalz.com
    >
    >
    > "Luis Esteban Valencia" <> wrote in message
    > news:...
    > > How would I quickly read several records (rows) from a SQL table, change
    > > the
    > > key in each (recordid) and insert them back into the same table thus
    > > creating duplicates.
    > >
    > > I'm reading the rows like this:
    > >
    > > Dim strSQL As String = _
    > > "SELECT * FROM XMMProjDet " & _
    > > "WHERE Project = '" & Trim(txtProject.Text) & "' and
    > > ProposalNbr = " & Trim(txtCopyFrom.Text)
    > >
    > > Dim scnnSol As New SqlConnection(SQL_CONNECTION_STRING)
    > > Dim scmd As New SqlCommand(strSQL, scnnSol)
    > > scnnSol.Open()
    > > Dim myReader As SqlDataReader = scmd.ExecuteReader()
    > >
    > > Thanks much.
    > >
    > >
    > > --
    > > LUIS ESTEBAN VALENCIA
    > > MICROSOFT DCE 3.
    > > MIEMBRO ACTIVO DE ALIANZADEV
    > > http://spaces.msn.com/members/extremed/
    > >
    > >

    >
    >
    Luis Esteban Valencia, Jan 6, 2005
    #3
  4. Luis Esteban Valencia

    Curt_C [MVP] Guest

    Select ...fields...(ID + 1) as ID, into....

    --
    Curt Christianson
    Site: http://www.Darkfalz.com
    Blog: http://blog.Darkfalz.com


    "Luis Esteban Valencia" <> wrote in message
    news:%23Yjk$...
    > Yes, this would work BUT the recordid would be duplicated. I need to be
    > able to change just one or two fields in each record as they are copied.
    > I'm trying to avoid reading the row and copying ALL the values out to
    > individual vars (there are a lot of columns), change the two vars that I
    > need and then insert them into the table
    >
    > --
    > LUIS ESTEBAN VALENCIA
    > MICROSOFT DCE 3.
    > MIEMBRO ACTIVO DE ALIANZADEV
    > http://spaces.msn.com/members/extremed/
    > "Curt_C [MVP]" <software_AT_darkfalz.com> escribió en el mensaje
    > news:...
    >> Select into
    >>
    >> --
    >> Curt Christianson
    >> Site: http://www.Darkfalz.com
    >> Blog: http://blog.Darkfalz.com
    >>
    >>
    >> "Luis Esteban Valencia" <> wrote in message
    >> news:...
    >> > How would I quickly read several records (rows) from a SQL table,
    >> > change
    >> > the
    >> > key in each (recordid) and insert them back into the same table thus
    >> > creating duplicates.
    >> >
    >> > I'm reading the rows like this:
    >> >
    >> > Dim strSQL As String = _
    >> > "SELECT * FROM XMMProjDet " & _
    >> > "WHERE Project = '" & Trim(txtProject.Text) & "' and
    >> > ProposalNbr = " & Trim(txtCopyFrom.Text)
    >> >
    >> > Dim scnnSol As New SqlConnection(SQL_CONNECTION_STRING)
    >> > Dim scmd As New SqlCommand(strSQL, scnnSol)
    >> > scnnSol.Open()
    >> > Dim myReader As SqlDataReader = scmd.ExecuteReader()
    >> >
    >> > Thanks much.
    >> >
    >> >
    >> > --
    >> > LUIS ESTEBAN VALENCIA
    >> > MICROSOFT DCE 3.
    >> > MIEMBRO ACTIVO DE ALIANZADEV
    >> > http://spaces.msn.com/members/extremed/
    >> >
    >> >

    >>
    >>

    >
    >
    Curt_C [MVP], Jan 6, 2005
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Hazzard
    Replies:
    2
    Views:
    632
    Hazzard
    Apr 6, 2004
  2. Alex
    Replies:
    2
    Views:
    1,217
  3. Replies:
    26
    Views:
    2,106
    Roland Pibinger
    Sep 1, 2006
  4. Andrew Jocelyn
    Replies:
    2
    Views:
    1,520
    Allen Chen [MSFT]
    Apr 27, 2009
  5. Derek Fountain

    Quick and easy way to check a port

    Derek Fountain, Jul 29, 2005, in forum: Perl Misc
    Replies:
    1
    Views:
    97
    Josef Moellers
    Aug 1, 2005
Loading...

Share This Page