Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
whitelockben
Starting Member
1 Post |
Posted - 2014-06-10 : 05:46:10
|
Hi all, I am looking for some assistance on creating a trigger that will remove a special character ('*') from a field on insert or update, if it exists in that field of the record being inserted or updated.Can anyone point me in the right direction please? |
|
djj55
Constraint Violating Yak Guru
352 Posts |
Posted - 2014-06-10 : 08:30:06
|
Look at instead of trigger. I think there might be a better way but I cannot remember right now.djj |
|
|
Bustaz Kool
Master Smack Fu Yak Hacker
1834 Posts |
Posted - 2014-06-11 : 19:07:40
|
[code]create trigger tr_iu_MyTable on dbo.MyTablefor insert, updateasupdate mtset MyColumn = Replace(mt.MyColumn, '*', '')from dbo.MyTable mtinner join inserted i on i.MyKey = mt.MyKey[/code]??? Too often we enjoy the comfort of opinion without the discomfort of thought. - John F. Kennedy |
|
|
ScottPletcher
Aged Yak Warrior
550 Posts |
Posted - 2014-06-24 : 17:40:31
|
[code]CREATE TRIGGER table_name_TR_INS_UPDON dbo.table_nameAFTER INSERT, UPDATEASSET NOCOUNT ON;UPDATE tnSET data_column = REPLACE(data_column, '*', '')FROM dbo.table_name tnINNER JOIN inserted i ON i.key_col = tn.key_col --AND i.key_col2 = tn.key_col2WHERE i.data_column LIKE '*'GO[/code] |
|
|
|
|
|