Click here to Skip to main content
15,881,712 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,
currently i tried to understand, what this does:
SQL
convert(varchar(20),((preis)*@prozent),0) as PreisPro



So far as i understand, it uses the field "preis", converts it to varchar(20), multiplies it with the variable "@Prozent" (Percent) and gives it out as "PreisPro".

But what exactly does the Zero number after "@Prozent"?

I'm using MS-SQL.

What I have tried:

I looked into: CAST and CONVERT (Transact-SQL) | Microsoft Docs[^].

There i found the table "float and real styles". Is that number "0" meant?
Posted
Updated 9-May-18 4:25am
Comments
gardnerp 9-May-18 10:20am    
Not posting as an answer since I'm not 100% positive but it looks like the precision. (e.g. a 0 might return "3" while a 4 might return "3.1416"). Why not just run a select statement and modify it to see the result?

1 solution

It's a "style" code: SQL Server CONVERT() Function[^] - it's only used for DateTimes, Floats, and Money.
In this case, it probably specifies "No comma delimiters, 2 digits to the right of decimal" as it says in the link.
 
Share this answer
 
Comments
Sascha Manns 9-May-18 10:43am    
Thank you very much for clarifying :-)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900