Author |
Topic |
micnie_2020
Posting Yak Master
232 Posts |
Posted - 2009-05-21 : 22:34:01
|
Dear all,Warmest Regards.How to auto Upper case for a column what ever style font they key in either small/cap; all character will auto convert to be upper case in database column by trigger. Did any one here know the solution?Please adviseThank youRegards,Michelle |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2009-05-21 : 22:40:30
|
[code]create trigger tu_table1 on table1 for updateasbegin update t set col = upper(i.col) from table1 t inner join inserted i on t.pk = i.pkend[/code] KH[spoiler]Time is always against us[/spoiler] |
|
|
micnie_2020
Posting Yak Master
232 Posts |
Posted - 2009-05-21 : 23:09:05
|
Dear Sir,Great Solution. Thank you very much.I have do ammendments using for insert, here is the solution:-SET QUOTED_IDENTIFIER ON GOSET ANSI_NULLS ON GOALTER trigger upp_addressbook on addressbook for insertasbegin update t set givenname = upper(givenname) from addressbook t endGOSET QUOTED_IDENTIFIER OFF GOSET ANSI_NULLS ON GORegards,Michelle |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2009-05-21 : 23:11:49
|
quote: Originally posted by micnie_2020 Dear Sir,Great Solution. Thank you very much.I have do ammendments using for insert, here is the solution:-SET QUOTED_IDENTIFIER ON GOSET ANSI_NULLS ON GOALTER trigger upp_addressbook on addressbook for insertasbegin update t set givenname = upper(givenname) from addressbook t endGOSET QUOTED_IDENTIFIER OFF GOSET ANSI_NULLS ON GORegards,Michelle
That will updates ALL records in the table every time record(s) are inserted. You should INNER JOIN to the inserted table as in my example. KH[spoiler]Time is always against us[/spoiler] |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-05-22 : 03:31:11
|
why are you concerned about this in first place? Regardless of the case in which you store the data, you can always display the data in case you want in front end using formatting functions. I don't prefer using trigger just to change case of data that is stored unless i'm using some case sensitive collation for my database. |
|
|
micnie_2020
Posting Yak Master
232 Posts |
Posted - 2009-05-22 : 04:15:46
|
Dear Sir,KH - Thanx for pointing my mistake.Visakh16 - I now in front end can do it, but just wanted to know the method of using trigger to do such thing. To expand more knowledge about this, so at least the skill can be expanded even seem useless to others; everyone have different style. I love to explore... :)Thanx for your reply, guys.Regards,Michelle |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-05-22 : 04:22:25
|
ok...no problem in exploring :). i was just telling that in practical case i would have prefered to let front end do this |
|
|
|