If you need to alter existing datatypes in the event of a SQL Server Datatype issue for capacity planning or conversion process this simple schema script may come in handy
2007-10-02 (first published: 2002-06-20)
15,451 reads
If you need to alter existing datatypes in the event of a SQL Server Datatype issue for capacity planning or conversion process this simple schema script may come in handy
-- Alteration of existing data types -- Allows the existing data type to be changed as runnable -- Script -- Cr Date; 03-14-2003 -- Jbabington@hotmail.com -- Data types are defined in the where clause -- Only use the CHARACTER_MAXIMUM_LENGTH values with caution -- Data type usage issues should be used only by highly -- Exp.dba as there are negative implications if not -- followed correctly SELECT 'ALTER TABLE ' + Table_name + ' ALTER COLUMN ' + Column_name + ' ' + data_type + '' --+ '(' +CAST(CHARACTER_MAXIMUM_LENGTH AS Varchar)+ ')' FROM INFORMATION_SCHEMA.COLUMNS --WHERE data_type = 'numeric'