CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1
    Join Date
    Dec 2009
    Posts
    90

    INSERT after SELECT statement

    Hello again

    I am trying to select a record from a database and then amend one column in this record. I am unsure of how to code this SQL statement for a SQL Server database. Can anyone shed some light on this issue?

  2. #2
    Join Date
    May 2007
    Location
    Denmark
    Posts
    623

    Re: INSERT after SELECT statement

    Just to be sure, you want to add a column to a table?
    It's not a bug, it's a feature!

  3. #3
    Join Date
    May 2009
    Location
    Bengaluru, India
    Posts
    460

    Re: INSERT after SELECT statement

    if you are trying to ammend one column then it is not called inserting , inserting means adding a row to the table...

  4. #4
    Join Date
    Apr 2010
    Posts
    2

    Re: INSERT after SELECT statement

    If you are adding one more column to the table then you will need Alter Table statement query, if you are adding a new row in the table then you will need Insert into statement query.

    Hope this helps.

  5. #5
    Join Date
    Oct 2004
    Location
    Rocket City
    Posts
    220

    Re: INSERT after SELECT statement

    If you are amending a value in an existing row, column then you need an UPDATE...SET... sql.

  6. #6
    Join Date
    Dec 2009
    Posts
    90

    Re: INSERT after SELECT statement

    Quote Originally Posted by zips View Post
    If you are amending a value in an existing row, column then you need an UPDATE...SET... sql.
    Thats what I needed Thanks for the replies everyone.

  7. #7
    Join Date
    Dec 2007
    Posts
    234

    Re: INSERT after SELECT statement

    INSERT the record into the table, then using the PKey, select the row and UPDATE it.... is there a reason the value can't be set correctly when inserting the data in the first place?

    -tg

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured