Skip to content

Instantly share code, notes, and snippets.

@ianoxley
Created February 7, 2011 16:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ianoxley/814695 to your computer and use it in GitHub Desktop.
Save ianoxley/814695 to your computer and use it in GitHub Desktop.
Changes all varchar columns to nvarchar in SQL Server
SELECT 'ALTER TABLE [' + TABLE_SCHEMA + '].[' + TABLE_NAME + '] ALTER COLUMN [' + COLUMN_NAME + '] nvarchar(' + CAST(CHARACTER_MAXIMUM_LENGTH As NVARCHAR) + ');'
FROM INFORMATION_SCHEMA.COLUMNS
WHERE DATA_TYPE = 'VARCHAR';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment