Reputation: 31
I have a SQL server Table that has a varchar
column that can save up to 4 characters
When we insert a value 963 into this column we have to add a leading "0" to this
for example:
Can we add a AFTER trigger to this table, to check if the value inserted is less than 4 digits, and to update the same value in that column with Leading "0"s appended to that value
Will this affect the performance of the Trigger? Is it a good practice to have a trigger to update the value in the same table?
Upvotes: 0
Views: 489
Reputation: 24619
Yes, you can create a trigger and for one operation it almost did not affect the performance.
Another way is to change the value when it use in select. e.g
select right('0000' + column, 4), ....
Upvotes: 1