How can I show the zero at the starting of a number in SQL/Sybase?

故事扮演 提交于 2019-12-24 09:10:06

问题


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.



来源:https://stackoverflow.com/questions/30970337/how-can-i-show-the-zero-at-the-starting-of-a-number-in-sql-sybase

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!