I would like to get an error when assigning a longer varchar to a variable and no silent truncation. Are there any settings?
This truncates silently:
declare @code varchar(10)
set @code = 'This is too long'
select @code
Inserting a varchar into a smaller Table column
create table test (col1 varchar(10));
insert into test values ('This is too long');
yields an error:
Meldung 8152, Ebene 16, Status 14, Zeile 2
String or binary data would be truncated.
The statement has been terminated.