MS SQL 2012 Add Column as Float Adds it as Real

Hi

This is really annoying me!  I have 2 lines which state:

ALTER TABLE ROSS_LIVE ADD Net_Amount float (20) default (0) NOT NULL;
GO

It creates the column but as a real, not a float.  Could someone please tell me what I'm doing wrong?  I've copied the code for another project/query I wrote and that one doesn't give me any problems.

I'm awarding 500 points for a quick and working solution.

Thanks
Sarah
ScuzzyJoAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Vitor MontalvãoMSSQL Senior EngineerCommented:
Why do you say it's a real?
ScuzzyJoAuthor Commented:
Hi Vitor

I right-clicked on the table, selected Design and that's what it told me it was.

Thanks
Sarah
Vitor MontalvãoMSSQL Senior EngineerCommented:
Interesting. I did the test and got same result.
In MSDN article about float and real data types you can read: "SQL Server treats n as one of two possible values. If 1<=n<=24, n is treated as 24. If 25<=n<=53, n is treated as 53."
So I did a test by creating a column as float(25) and really shows as float. Or you've find a bug or it's really the behavior.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Active Protection takes the fight to cryptojacking

While there were several headline-grabbing ransomware attacks during in 2017, another big threat started appearing at the same time that didn’t get the same coverage – illicit cryptomining.

ScuzzyJoAuthor Commented:
Wow!  You're right.  Thanks.  I changed it to 25 and it's now creating as a float.  That's really weird!  You don't always need a length of 25 when you create a float field.
Vitor MontalvãoMSSQL Senior EngineerCommented:
The default is 53! :O
Anyway if you need to store money values you have money and smallmoney data types.
PortletPaulEE Topic AdvisorCommented:
The ISO synonym for real is float(24).
https://msdn.microsoft.com/en-AU/library/ms173773.aspx

i.e. It was already a "Float" but called a "Real" (confusing? yes, but I didn't make it that way)
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server

From novice to tech pro — start learning today.