Skip to content
Advertisement

Need to copy all fields value of specific item on table to another item in SQL Server

SQL Server database snapshot:

enter image description here

I need to copy this selected article data to another article. Need a query in SQL to solve this issue.

Advertisement

Answer

If I understand, you wan the IEDetails table to have the values for art_id = 7545 copied with a different art_id value while still retaining the original values? With the data shown, I am going to assume that the Id column is defined as an IDENTITY column

If so then this should work for you:

You could change where you get the values for @old_art_id and @new_art_id by using a different query than the SET statements.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement