1

I'm using SQL Server 2012 and I'm trying to insert values in an int column (Filenum)

INSERT INTO Tbl (Filenum, Fname, Sname, Tname, Lname, DOB, NatID, SexID, AdrsCtryID, AdrsStateID, AdrLin1, FileStatID, MarStatID, OcupID, Email, SSnum, Passnum, TelMob, TelLnd, TelWrk, TelWrkExt, TelInt, strno, Direction, AptNo, locality, adminLvl, postalcode, Contr, UsrID, LogID)
VALUES (@FileNum, @Fname, @Sname, @Tname, @Lname, @DOB, @NatID, @SexID, @AdrsCtryID, @AdrsStateID, @AdrLin1, @FileStatID, @MarStatID, @OcupID, @email, @SSnum, @Passnum, @TelMob, @TelLnd, @TelWrk, @TelWrkExt, @TelInt, @strno, @Direction, @AptNo, @locality, @adminLvl, @postalcode, @Contr, @UsrID, @LogID)

Values like (777777777) with 9 digits are allowed whereas 10 digit values give me this error

The changed value in this cell was not recognized as valid .net framework data type int32

Any idea why?

3
  • 2
    32 bit signed integers have a max value of 2,147,483,648 Commented May 23, 2017 at 18:53
  • 2
    Please tell me that you are not storing SSN in plain text. Commented May 23, 2017 at 19:01
  • 1
    actually I encrypt it and save it, yes, could you please correct me here if I m compromising Commented May 23, 2017 at 19:04

1 Answer 1

3

max size for 4 byte signed integer: 2147483648

Try using a bigint in sql server, and a 64bit signed int long in .net.

Reference:

Sign up to request clarification or add additional context in comments.

3 Comments

thanks for the promot help... I m using this field as a primary key,,, based on my humble knowledge, int are the best to be used as primary key in relational dbs, am i correct?
@AhmadAbuMaizar It is a good clustering key (primary key is clustered by default in sql server), yes. bigint will be fine too. Ever-increasing clustering key – the Clustered Index Debate……….again! - Kimberly Tripp
Thank you all so much, I really appreciate any input on how to save SSN efficiently

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.