HELP: How to copy rows to the same table

  • Hello,

    I'm fairly new to SQL Server and I'm looking around for answers to no avail here. I need to do this really quick so I'm going to use this forum.

    My question is if there's possible to use SQL statement to copy a few rows that met certain criteria and copy them to new rows in the same table? Or is this something that should be done in a stored procedure instead? I'm asking this because I have a list of data bound on a datagrid (in ASP.NET) and I'm supposed to give the user ability to copy everything while editing a few new parameters. I'm trying to stay away from using arrays because the list could get very big.

    Another thing that should be simple is since I'm new to this (you can tell from my question), what books would you recommend for me to read to get this up to speed. I'm fine with some basic SQL statement (coming from old version of MySQL before), but starting to learn nested SQL etc. If you could give me any recommendation, I'd greatly appreciate it.

    Thanks!

  • List of good books:

    http://qa.sqlservercentral.com/forums/shwmessage.aspx?forumid=8&messageid=151063

    Unfortunately, in middle of crisis so can't help for the other...  Except why not write an INSERT statement using same syntax as MySQL??



    Good Hunting!

    AJ Ahrens


    webmaster@kritter.net

  • Thanks for the reply and the books recommendation. I finally found it from other forum.

    Just for other newbies like me, the SQL command is:

    INSERT INTO tblName1 (Column1, Column2)

    SELECT Column1, Column2

    FROM tblName1

    WHERE ...

    Hope that helps.

    Best regards!

     

Viewing 3 posts - 1 through 2 (of 2 total)

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