如何在 SQL/Sybase 中的数字开头显示零? [英] How can I show the zero at the starting of a number in SQL/Sybase?

查看:62
本文介绍了如何在 SQL/Sybase 中的数字开头显示零?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想输入两个完全不同的数字,例如 012345678901234567890 所以我在 SQL/Sybase 上制作了这段代码

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'))'

但是当我执行 select 时,它显示给我:

But when I do a select, it shows me:

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

代替

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

推荐答案

BIGINT 值表示数轴上的一个点.

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'

使数据类型为 nvarchar(max) 以完成您所寻求的差异化.

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

这篇关于如何在 SQL/Sybase 中的数字开头显示零?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆