Technical Article

Alteration of Data Types

,

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'

Rate

1 (1)

You rated this post out of 5. Change rating

Share

Share

Rate

1 (1)

You rated this post out of 5. Change rating