I've created function which removes numbers from string
create function RemoveNumber(@inp nvarchar(50))
returns nvarchar(50)
as
begin
declare @out varchar(50)
if (@inp is NOT NULL)
begin
set @out = ''
while (@inp <> '')
begin
if (@inp like '[0-9]%')
set @out = @out + substring(@in, 1, 1)
set @inp = substring(@inp, 2, len(@in) - 1)
end
end
return(@out)
end
Then I wanted to use it inside the trigger
create trigger ut_RemoverName
on Worker
for insert
as
update Worker
set name = ut_RemoveNumber(name)
It doesn't see the function. But how to create loop from RemoveNumber inside the trigger?(Field name
- nvarchar(10)
)