September 21, 2015 at 2:01 am
Hello
I want to save 999999999 as real data in sql.
but it saved 1+E09.
Could you help me how can I save 999999999?
thanks alot
September 21, 2015 at 2:20 am
bkshn (9/21/2015)
HelloI want to save 999999999 as real data in sql.
but it saved 1+E09.
Could you help me how can I save 999999999?
thanks alot
Quick question, do you need an actual number or a floating point approximation of the number?
September 21, 2015 at 2:32 am
what is difference between them?
Could you help me in both?
thanks
September 21, 2015 at 2:42 am
If you need precise, use the Numeric or Decimal data types.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
September 21, 2015 at 3:00 am
You can use BIGINT Or varchar(Max) Or NVARCHAR(max) for this.
please Use below example for ref:
DECLARE @temptbl TABLE (ID [nvarchar](max))
INSERT INTO @temptbl (ID)
VALUES (N'9999999999999999999999999999999999999999')
SELECT * FROM @temptbl t
September 21, 2015 at 3:11 am
schaudhary (9/21/2015)
You can use BIGINT Or varchar(Max) Or NVARCHAR(max) for this.
No, please don't suggest storing numbers in a varchar field at all, much less varchar(max). I highly doubt there's much interest in numbers over 8000 digits long.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
September 22, 2015 at 2:01 am
declare @temptbl table (ID bigint)
insert into @temptbl(ID)
values(99999999999999999)
select *
from @temptbl
try the script above. I just used a previously posted script and changed on data type only.
September 22, 2015 at 2:08 am
I want to save real datatype!!!
September 22, 2015 at 3:12 am
If you want to save it as REAL you will have to live with 1E+09 as REAL is actually FLOAT(24) and anything 24 or under is only a 7 digit precision so you cant save 999999999 as that's 9 digit precision.
Unless you go FLOAT(25) or above or use a fixed precision datatype like NUMERIC or DECIMAL.
September 23, 2015 at 6:54 am
bkshn (9/21/2015)
HelloI want to save 999999999 as real data in sql.
but it saved 1+E09.
Could you help me how can I save 999999999?
thanks alot
The question here is, do you know what the REAL datatype in SQL Server actually is? Also, what will this column hold? I mean, what is the purpose of the column? You might ne confusing the definition of REAL in the front-end with the definition of REAL in SQL Server and they're not the same. I strongly suspect you want the INT datatype in SQL Server based on what you've posted.
--Jeff Moden
Change is inevitable... Change for the better is not.
September 23, 2015 at 7:15 am
bkshn (9/22/2015)
I want to save real datatype!!!
Why?
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
Viewing 11 posts - 1 through 11 (of 11 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy