How to copy data from one column to another in the same table using the where clause and on SQL server management studio

Tsepo Kholoane 0 Reputation points
2024-04-05T08:56:25.51+00:00

I want to copy data from one column to another column with blank records. I also want to make use of the WHERE clause. I am using SQL Server Management Studio.

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
13,836 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. LiHongMSFT-4306 27,026 Reputation points
    2024-04-05T09:33:46.84+00:00

    Hi @Tsepo Kholoane

    Try this:

    ALTER TABLE TableName ADD New_Column VARCHAR(20)--SAME DATATYPE AS Old_Column;
    UPDATE TableName SET New_Column = Old_Column
    

    Best regards,

    Cosmog Hong


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.