Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7864807
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T23:53:44+00:00 2026-06-02T23:53:44+00:00

In SQL Server, is there any easy way to achieve below scenario? In one

  • 0

In SQL Server, is there any easy way to achieve below scenario?

In one of my table, I have around 20 columns and primary key field where we put generated number (it’s not autogenerated field). For a reason, we wanted to duplicate a record of certain primary key value with different primary key value.

So this could be my table data (assume KEYxxx is primary key field)

KEY001  AA1  AA2 AA3 AA4 ... AA20
KEY002  AA1  AA2 AA3 AA4 ... AA20

I am trying to insert a new row with same data: KEY001 as KEY002

I have tried using this query here to do this, but failed, couldn’t find a way to insert a new primary key value (KEY002) to this query.

INSERT INTO mytable (FIELD1, field2,...field20) 
    SELECT (FIELD1, field2,... field20) 
    WHERE field_primary_key = 'KEY001' 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T23:53:46+00:00Added an answer on June 2, 2026 at 11:53 pm

    Instead of specifying the PK column in the SELECT list, replace it with a literal value for the new key:

    INSERT INTO mytable (FIELD_PK, field2,...field20) 
    SELECT 'KEY002', field2,...field20
    from mytable
    where field_primary_key='KEY001'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there any easy way of changing the SQL Server Management Studio default 'Project'
Is there any way to add a SQL Server Database Diagram to source control?
Is there any way to debug a SQL Server 2008 query?
Is there any way to pre compile stored procedures in SQL Server? My requirement
In SQL Server, is there any way to check whether the changes in the
Is there an easy way to remove an identity from a table in SQL
Is there any easy way to track/monitor all the SQL of the queries, executed
Is there any way in SQL Server to get the results starting at a
Is there any way to connect to a SQL Server from an Android application
Apart from Sql server profiler ,is there any third party user friendly tool available

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.