Easwaran Paramasivam
asked on
Which one is best approach to alter a datatype?
A table tAudit contains Millions of Millions of records. Now I would like to change a dataype of of a column int to bit. Which one is faster whether Alter column option or
Rename the column
Create a new column with bit datatype with existing name.
Update the new column with old column value
Drop the old column.
Please suggest.
Rename the column
Create a new column with bit datatype with existing name.
Update the new column with old column value
Drop the old column.
Please suggest.
please check this article
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
The advantage of creating a new column updating then dropping is that you can step back not really the speed. I do it this way just in case something fails in the process.
I would definitely use the ALTER TABLE method but I would run something like
SELECT CAST(myColumn as bit) FROM tAudit
to check for any conversion errors.
SELECT CAST(myColumn as bit) FROM tAudit
to check for any conversion errors.
ASKER CERTIFIED 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.