Copy the table change values ​​into 1 column and paste them into the same table

The title basically summarizes it pretty much with what I'm trying to accomplish here.

A bit more information, I have a table with 4 columns. I need an exact copy, but I need to change the values ​​of only one column.

Assume that the customer number is 123456 in the column (other values ​​do not matter).

How to copy the entire table and change the customer number to 123457 and paste this copy back into the same table.

If everything goes right, I should have twice as much (there is only one client in the database), as before, when only the client number changed.

I am using MSSQL2008 R2.

+6
source share
1 answer

try it

INSERT CustomerTable(customer, Field2, Field3, Field4) SELECT 123457, Field2, Field3, Field4 from CustomerTable WHERE customer = 123456 
+9
source

Source: https://habr.com/ru/post/905064/


All Articles