I have below two tables in SQL server database. I have a procedure which performs validation for each record on Transactions table & save the comma separated error in “Error_Messages
” column. ErrorMessages
table contains all the error messages.
Create table dbo.Transactions(ID INT IDENTITY(1,1) Primary Key, Error_Messages VARCHAR(MAX))
Create table dbo.ErrorMessages(Field_Type varchar(100), Code VARCHAR(100), Error_Msg VARCHAR(300))
truncate table Transactions
insert into Transactions(Error_Messages) values ('First Name is should not contain special symbols, First name lenght should be less than 250 chars, Last name is mandatory');
truncate table ErrorMessages
insert into ErrorMessages values('FirstName', 'FirstName_Symbol', 'First Name is should not contain special symbols,');
insert into ErrorMessages values('FirstName', 'FirstName_Length', 'First name lenght should be less than 250 chars,');
insert into ErrorMessages values('LastName', 'LastName_Mandatory' ,'Last name is mandatory,');
User can fix the error & try to run the validation again. How can I replace all occurrences of errors from “Error_Messages” field before running the validation.
For eg. If I am running the validation for field type “FirstName” then I will replace all the errors related to first name from “Error_messages” field of Transactions table, & keeping rest of the errors as is.