In SQL Server, is there any easy way to achieve the below scenario?
In one of my tables, I have about 20 columns and a primary key field where we put the generated number (this is not an auto-generated field). For some reason, we wanted to duplicate a record of a specific primary key value with a different primary key value.
So this could be my table data (suppose KEYxxx is a primary key field)
KEY001 AA1 AA2 AA3 AA4 ... AA20
KEY002 AA1 AA2 AA3 AA4 ... AA20
I am trying to insert a new row with the same data: KEY001howKEY002
I tried to use this request here for this, but could not, could not find a way to insert a new primary key value ( KEY002) into this request.
INSERT INTO mytable (FIELD1, field2,...field20)
SELECT (FIELD1, field2,... field20)
WHERE field_primary_key = 'KEY001'