sql server - update nvarchar not null field length -
i can update column's length if in null when created
mycolumn1 nvarchar(12) null
my query:
alter table mytable alter column mycolumn1 nvarchar(13) null
but how can change length if column not null?
mycolumn2 nvarchar(12) not null alter table mytable alter column mycolumn2 nvarchar(13) not null
when try sql server says
msg 4902, level 16, state 1, line 1
cannot find object "mycolumn2" because not exist or not have permissions.
i have permission because admin , table's column exist.
guys response... here table structure
create table [dbo].[mytable]( [mykey] [int] identity(1,1) not null, [mycolumn1] [nvarchar](12) null, [mycolumn2] [nvarchar](12) not null, constraint [pk_mytable] primary key clustered ( [mykey] asc )with (pad_index = off, statistics_norecompute = off, ignore_dup_key = off, allow_row_locks = on, allow_page_locks = on) on [primary] ) on [primary]
column names case sensitive. please try
alter table mytable alter column [mycolumn2] nvarchar(13) not null
i've tried , works fine on sqlserver2012.
Comments
Post a Comment