When we use SQL to do query insertion, we usually use SQL to query a string number, which is made up of numbers. In order to unify the aesthetics, we record the number, the uniform specified number of digits, the number of bits we left 0. If the number 66, we specify the number of digits is 5, the saved data should be 00066. How should such an operation be implemented in SQL?
First, the query statement: Right (' 0000 ' +cast (' 123 ' as nvarchar (50)), 4)
Statement interpretation: Formula right (' Bits ' +cast (field to be judged as nvarchar (50)), number of digits)
PS: The above query statement is placed in the Select, the query result is to judge all the fields to the left 0 processing.
Example: Querying the user table for all user numbers, and the number of 5-bit 0 processing
User table:
Query statements and results:
On the technique of using SQL statements to implement a string of digits less than 0 on the left