Skip to content
Advertisement

Extract string from the first position that’s not “0” SQL

I am trying to find the first position of a value that’s not “0” in a string so that I can extract the values that come after. The strings are all length 10. The strings all start with D and then a variable amount of “0” and I need to find the first position in the string that’s not a “0”. Examples:

I first wanted to do it like this:

But I’ve now read that InStr doesn’t accept <>, ! or NOT. How can I extract the string from the first position where the value isn’t “0”?

Advertisement

Answer

Use MID() to remove the 1st char and then add 0 to get only a numeric result (Access will do an implicit cast to integer):

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement