Answer the question
In order to leave comments, you need to log in
How to create a trigger in MSSQL to update on insert and update?
c MSSQL almost did not work, and with triggers and at all.
You need something - there is a table where there is a PHONE column field of the nvarchar (32) type, and here managers enter phones without any format through the program, and you need to search by number. I want to create a column, for example, METAPHONE, and push the phone purely numbers from the PHONE field there. Actually, tell me how to process all current records and make a trigger that, with each new insertion and update, would enter into metaphone only numbers from the phone field? Alas, nothing can be changed in the program itself, but with triggers I think it can be done.
The search will be performed by connecting to the database from the outside from PHP, the server with the database runs on Windows.
MS SQL 2008 R2
Answer the question
In order to leave comments, you need to log in
Do managers enter data using direct access to the database or through a procedure? Usually, if the developer isn't ummm... a weird weirdo, it's done through a procedure. It makes sense to look at it and change it.
Well, if you really need a trigger - yes, it is possible, there is absolutely nothing complicated, so create trigger ... on [tablename] ... for update, insert in it, check that the Phone field is being updated / inserted and do insert-update the value you need. Work for half an hour, if you read the help on create trigger, an inexperienced person. It is better to make a trigger separately for an update and insert your own.
There will be a plug - well, I don’t know, try to contact me if you have an interesting offer. current records, of course, should be processed simply by Update'om.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question