create trigger which will remove numbers from string

I’ve created function which removes numbers from string

create function RemoveNumber(@inp nvarchar(50))
returns nvarchar(50)
declare @out varchar(50)
if (@inp is NOT NULL)
    set @out = ''
    while (@inp <> '')
        if (@inp like '[0-9]%')
            set @out = @out + substring(@in, 1, 1)
        set @inp = substring(@inp, 2, len(@in) - 1)

Then I wanted to use it inside the trigger

  • Complicated SQL query for a running total column
  • Any way to integrate SQL Server 2016 with MySql server using linked server?
  • SQL server joining where fields different type
  • What is the performance penalty of XML data type in SQL Server when compared to NVARCHAR(MAX)?
  • Better way to check condition instead of repeated Case When
  • Create a stored procedure to find out employees who has overtime from timesheet table
  • create trigger ut_RemoverName
    on Worker
    for insert
    update Worker
    set name = ut_RemoveNumber(name)

    It doesn’t see the function. But how to create loop from RemoveNumber inside the trigger?(Field namenvarchar(10))

  • sql server if block errors when running a stored proc inside - gives a syntax error
  • SQL Server xml copy values of one node to another
  • How to fix “Must declare the scalar variable” error when referencing table variable?
  • What is wrong with Cursors?
  • Running total based on Data column
  • Order of execution in SQL Server variable assignment using SELECT
  • One Solution collect form web for “create trigger which will remove numbers from string”

    I guess you need this

    create trigger ut_RemoverName on Worker
    for insert
    UPDATE w
    SET Name = dbo.RemoveNumber(
    FROM Worker w JOIN inserted i ON w.Id = i.Id

    Demo on SQLFiddle

    MS SQL Server is a Microsoft SQL Database product, include sql server standard, sql server management studio, sql server express and so on.