tommym121
asked on
SQL - how to add data to a new column of a table
I have created a table with data. Now I realize I need to add one more column.
I know I can use Alter to add a new column.
Now how am I add this data to the table?
I am using SQL Server 2008
I know I can use Alter to add a new column.
Now how am I add this data to the table?
I am using SQL Server 2008
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks
ASKER
CustomerID, FirstName, LastName, Age, Gender
I have then create a table called TableX where I put only
Columns
CustomerID, FirstName, LastName
and inserted data to TableX
Now I realize I miss the Gender in TableX
I use Alter to add column Gender into TableX
How can I add gender data to each records
say I have this set of data in CustomerTable
123, Mary, Jane, 23, F
124, Jack, Wood, 34, M
456,Matt, Tripper,67, M
345, Jane, Ford, 45, F
Now in my TableX, I have
123, Mary, Jane
124, Jack, Wood
456,Matt, Tripper
345, Jane, Ford
What SQL I need to write to update my TableX like below (after I add the column 'Gender')
123, Mary, Jane, F
124, Jack, Wood, M
456,Matt, Tripper, M
345, Jane, Ford, F