Forum Discussion
smpa01
Community Champion
2 years agoALTER TABLE DW
I have been trying to use ALTER Table Alter Column on a data warehouse table but it does not sem to be supported.
I have a table that has a column a column [row_sum] [bigint] NULL
I want to c...
cgonzalesrod
4 months agoNew Member
I found this to solve the problem. Please note that the column data type I was trying to change was 'day'.
-- 1. Add a new column with the correct data type
ALTER TABLE Dim_Dates ADD day_int INT;
-- 2. Copy data to the new column
UPDATE Dim_Dates SET day_int = CAST(day AS INT);
-- 3. Delete original column
ALTER TABLE Dim_Dates DROP COLUMN day ;
-- 4. Rename new column
EXEC sp_rename 'Dim_Dates .day_int', 'day', 'COLUMN';