I'm trying to make a column smaller by executing this: -- decrease the description field to 500 charactersif exists (select * from information_schema.columns where table_name = 'registry' and column_name = 'description' and character_maximum_length = 700)begin raiserror('Decrease registry.description field to 500 varchars...', 0, 1) with nowait alter table registry alter column "description" varchar(500) not null if @@error <> 0 begin rollback transaction return endendGO
but I get the following error when I try and execute that statement: Server: Msg 8152, Level 16, State 9, Line 1String or binary data would be truncated.The statement has been terminated.
Obviously I have some data in there that's longer than the 500 char limit I'm setting this to, but I don't care if I lose data. How can I force the reduction of the column length so the statement will run? Thanks.