Timeline for Ontario Health Card mod 10 validation
Current License: CC BY-SA 3.0
7 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Jan 26, 2018 at 2:07 | comment | added | Raul | this is so much cleaner than the OP's var table, loops and update spamming solution. Not to talk about the execution plan. | |
Jan 23, 2018 at 19:53 | comment | added | Bacon Bits |
@DanBracuk If you're really concerned about the division, you can change them to ROUND((CAST(SUBSTRING(inputString, 1, 1) AS INT) * 2) / 10, 0, 1) . That's about as explicit as you can be. The ROUND(value, 0, 1) call will explicitly truncate the fractional portion of the quotient (although as dnoeth said, since we're doing integer division here in T-SQL, we shouldn't get that in the first place).
|
|
Jan 20, 2018 at 15:56 | comment | added | dnoeth |
You tagged T-SQL and here it's working correctly (automatically casting the string to an int). But for other DBMSes you might have to CAST(Substring(inputString, n,1) AS INT)
|
|
Jan 20, 2018 at 15:35 | comment | added | Dan Bracuk | Thanks for the answer but I think it's incorrect. Doing math on characters aside, dividing by 10 is going to result in floating point numbers which is inappropriate for this situation. | |
Jan 20, 2018 at 14:30 | history | edited | dnoeth | CC BY-SA 3.0 |
deleted 22 characters in body
|
Jan 20, 2018 at 14:21 | history | edited | dnoeth | CC BY-SA 3.0 |
deleted 1 character in body
|
Jan 20, 2018 at 12:50 | history | answered | dnoeth | CC BY-SA 3.0 |