sql/sybase varchar length -


so trying make code document. if put 01234567890 , 1234567890 on table, should stay there. when put 12345667890 , table, number different like: 1234566789 (the 0 gone!)

plus length must 11.

if can me/understand me, thank you.

create table doctors(     fullname varchar(35) not null,     document varchar(11) not null,     salary bigint null,     homeaddress varchar(35) null,      phone bigint not null,      cellphone bigint not null,     speciality varchar(20) not null,     birthdate date not null,     gradedate date not null,     workingdate date not null,     constraint pk primary key (document) , check(document between '0' , '99999999999'),     constraint validcellphone  check (cellphone between 3000000000 , 3029999999 or cellphone between 3100000000 , 3129999999 or cellphone between 3150000000 , 3169999999),     constraint validspeciality check (speciality in('medicina general','ginecologia','traumatologia','pediatria')),     constraint validdates  check (birthdate < gradedate , birthdate < workingdate , gradedate< getdate() , workingdate< getdate() , gradedate<workingdate),     constraint antiquity check (datediff(dd, gradedate, getdate() )>1461),     constraint validphone check(phone between 1000000 , 9999999) ); go> 

if tried int previously,

01234567890

is not number. it's string.

1234567890

is number.

sql able recognize zeros not needed define number, ignores them. if want dispaly value 01234567890 application, i'd suggest doing formatting on application side. way number stored in sql still number if want addition, aggregation, or other calculations. if have store '01234567890', need convert character field; char, varchar, nvarchar, nchar.


Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -