Howdy,
Is it possible to create a trigger for a table, that checks the length of a string before it actually saves it to the table ? If the size of the string is greater that the size of the column length, I want it to save a truncated string.
So far I have the following, but I have no idea how to save a truncated string:
create trigger trtest
on test
for insert, update
as
declare @strsize smallint,
@colsize smallint
if update(testfield)
begin
select @colsize = col_length('test', 'testfield')
select @strsize = len(testfield) from TEST
if @strsize > @colsize
???
end;
Thanks in advance.
WB
Is it possible to create a trigger for a table, that checks the length of a string before it actually saves it to the table ? If the size of the string is greater that the size of the column length, I want it to save a truncated string.
So far I have the following, but I have no idea how to save a truncated string:
create trigger trtest
on test
for insert, update
as
declare @strsize smallint,
@colsize smallint
if update(testfield)
begin
select @colsize = col_length('test', 'testfield')
select @strsize = len(testfield) from TEST
if @strsize > @colsize
???
end;
Thanks in advance.
WB