I've found this very neat function online and I want this function to work with my add-procedure for table customer, so that for example a "name" won't take rubbish inserts.ALTER FUNCTION [dbo].[fn_ReplaceNotAlfaChar] ( @STR VARCHAR(MAX) )RETURNS VARCHAR(MAX)AS BEGIN IF PATINDEX('%[^a-z ]%', @STR) = 0 RETURN @STR WHILE PATINDEX('%[^a-z ]%', @STR) > 0 SELECT @STR = STUFF(@STR, PATINDEX('%[^a-z ]%', @STR), 1, ' ') RETURN @STR ENDthe add procedure has a normal insert statement like this. INSERT INTO Customer ( Name, FirstName, .... ) VALUES ( @Name, @FirstName, .... ) COMMIT TRANSACTION
Could I place the function inside this procedure to handle inputs or do I need a trigger to call the function when a name was inserted?But maybe there are other ways to deal with this, so what's a good solution and how can I achieve it?Thanks for reading.