Application of Simple Adjustment Function in SQL

xiaoxiao2021-03-06  41

Determine if a digital length is two words, if not, turn a number to two digits

If the value within the database is "9", the function is changed to "09" when reading.

The SQL code is as follows:

Create function fn_chg2 (@P varchar (2))

Returns varchar (2)

AS

Begin

IF LEN (@P) <2

Begin

Set @ p = '0' @p

end

Return @P

end

转载请注明原文地址:https://www.9cbs.com/read-55256.html

New Post(0)