SQL Server – How to Duplicate Column in Same Table

sql servert-sql

I'm pretty basic with SQL and need help with the following task:

I already have a table with data in it. What I would like to do is to Duplicate a Column (Including the data) in the same table but with a different column name. Is this possible?

Any help would be greatly appreciated.

Best Answer

You can just add the new column to the table as nullable, either with SQL Server Management Studio by right clicking on the Table and clicking "Design" or by using an ALTER TABLE statement like this ALTER TABLE TableName ADD NewColumnName DataType NULL.

Then you can UPDATE that new column from the old column like so:

UPDATE TableName
SET NewColumnName = OldColumnName