Steve Stedman gets rid of leading zeroes:
When working with data in SQL Server, there may be times when you need to remove leading zeros from a string. This task can be particularly common when dealing with numerical data stored as strings, such as ZIP codes, product codes, or other formatted numbers. In this blog post, we’ll explore several methods to remove leading zeros in SQL Server.
I’m not sure I see the reason to use anything other than CAST()
(or, better yet, TRY_CAST()
), but Steve does show two other methods.