SQLTeam.com | Weblogs | Forums

Update column types on multiple columns within multiple tables

tsql
sql2008
sql2012
sql2014
sql2008r2

#1

I need to change datatypes of multiple columns within multiple tables. How can I do this? Is there any stored procedure that will allow me to change on sys.types table?

Thanks.


#2

There's no Swiss Army Knife for this sort of thing. General approach:

  1. Create new tables with new types
  2. Copy data from current tables to new tables
  3. Rename current tables to table_name_old or something
  4. Rename new tables to current table names

Do it all outside of business hours.


#3

Thank you.