How can I show the zero at the starting of a numbe

2019-08-08 19:00发布

问题:

I want to put two totally different numbers like 01234567890 and 1234567890 So I made this code on SQL/Sybase

create table DOCTORS(
    document bigint not null ,
);
GO

Insert into DOCTORS values(CONVERT(INT, '01234567890'))

Insert into DOCTORS values(CONVERT(INT, '1234567890'))'

But when I do a select, it shows me:

document
--------
1234567890
----------
1234567890

instead of

document
--------
01234567890
----------
123456789

回答1:

BIGINT values represent a spot on the number line.

1234567890 = 01234567890 = 1234567890.000

To make these values differentiate from each other, they cannot be any sort of a numeric data type.

Strings, however, can make this differentiation.

'1234567890' != '01234567890' != '1234567890.000'

Make the data type nvarchar(max) to accomplish the differentiation you seek.