Home Forums SQL Server 2008 SQL Server Newbies SQL query statement for copying data from different rows to different rows RE: SQL query statement for copying data from different rows to different rows

  • zahid_7777 (10/8/2012)


    I have a table (dbo.ACCOUNT_INF) with fields company_code (secondary key), accounts_code (unique) and other columns.

    I like to copy rows containing a specific company_code and from accounts_code = 1 which is unique to accounts_code 100 along with full records (rows)

    to a another company_code starting from a specific accounts_code in the same table dbo.ACCOUNTS_INF

    Post a SELECT query which returns the rows you want to clone, we'll show you how to do the rest.

    “Write the query the simplest way. If through testing it becomes clear that the performance is inadequate, consider alternative query forms.” - Gail Shaw

    For fast, accurate and documented assistance in answering your questions, please read this article.
    Understanding and using APPLY, (I) and (II) Paul White
    Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden