Treatment of 4

xiaoxiao2021-03-06  64

Because 4 in some people seem to be a not auspicious number, the number inside my recent system does not appear according to the customer's requirements.

Here is the SQL I want to say: declare @i @i @i @i @ le If the @i number has a number is 4, then add 1 until there is no 4. For example: @i = 1, @i = 2 @ i = 4, then @i = 5 @ i = 34, then @i = 35 @ i = 343, @i = 350

The following is a related solution: declare @i intset @ i = 3434567select Left (@i, cascharindex ('4', @ i) -1 When -1 Ten Len (@i) else Charindex ('4', @ i ) -1 end) Case Charindex ('4', @ i) -1 When -1 Then '' Else '5' end replicate ('0', len (@i) -case charindex ('4', @ i ) -1 When -1 Ten Len (@i) else Charindex ('4', @ i) end)

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

New Post(0)