31 March, 2014
0 Comments
1 category
The following code will update a column to varchar(max) only, when it does not already have the varchar(max) length.
-- Update column 'Name' length, it should be varchar(max). -- Note: varchar(max) has length '-1'. if ( ( select character_maximum_length from information_schema.columns where table_name=object_name(object_id('dbo.Table1')) and COLUMN_NAME = 'Name' ) <> -1 ) begin alter table dbo.Table1 alter column Name varchar(max) not null end
Tags: T-SQL
Category: Uncategorized