Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
hog
Constraint Violating Yak Guru
284 Posts |
Posted - 2006-05-03 : 16:05:13
|
| I know I have posted this before and have searched all variations of text to find it but can't!!If I want to calculate a sum say 20100 / 9000 what type do I need to use and how do I get the fractional part or to round up for that matter?20100 / 9000 = 2.2333333 or to round up = 3.I posted some while ago and someone told me the format to use....Thnx |
|
|
Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)
7020 Posts |
Posted - 2006-05-03 : 16:18:19
|
| You should read the Datatypes subject in SQL Server Books Online.CODO ERGO SUM |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2006-05-03 : 16:35:00
|
| To force the decimals without using CONVERT, you can do this:SELECT 20100/9000.0The reason you aren't getting the decimals currently is that both values are integers. This means you'll get an integer answer. You'll need to check out the data type precedence in BOL if you want to understand this better.Tara Kizeraka tduggan |
 |
|
|
hog
Constraint Violating Yak Guru
284 Posts |
Posted - 2006-05-03 : 17:15:54
|
| tKizer, thanks that was it! Michael, thanks I know this but unless you know what to type you are stuffed really. I try to find things in the forums and the BOL but unless you type the right phrase you wont find what you are looking for.For example looking for DataTypes, I entered DataType in the Contents, Index and Search in BOL and get hundreds of entries returned. Yes I admit that after reading through 10+ entries yes I get put off as I could be there for days only to not find the right thing.I am all for looking for answers for myself but unless I know what is the correct phrase to search for I am in the dark.Unless of course you can point me in the right direction on efficient searching?Thnx |
 |
|
|
Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)
7020 Posts |
Posted - 2006-05-03 : 18:06:34
|
quote: Originally posted by hog tKizer, thanks that was it! Michael, thanks I know this but unless you know what to type you are stuffed really. I try to find things in the forums and the BOL but unless you type the right phrase you wont find what you are looking for.For example looking for DataTypes, I entered DataType in the Contents, Index and Search in BOL and get hundreds of entries returned. Yes I admit that after reading through 10+ entries yes I get put off as I could be there for days only to not find the right thing.I am all for looking for answers for myself but unless I know what is the correct phrase to search for I am in the dark.Unless of course you can point me in the right direction on efficient searching?Thnx
I was suggesting that you read the Data Types subject in the Transact SQL Reference in SQL Server Books Online. The Transact SQL Reference is where you should look anytime you have a question about SQL.You mentioned that someone answered this question for you once before, and you forgot, so I thought it would be better for you to learn how to find the answer yourself.Do you expect people to keep answering this question everytime you forget? You need to learn how to find these things yourself if your are developing SQL, or it is going to take you a long time to get anything done.CODO ERGO SUM |
 |
|
|
hog
Constraint Violating Yak Guru
284 Posts |
Posted - 2006-05-03 : 19:24:57
|
| Well to be honest I have never gone into the Transact SQL Help in BOL!I usually press shift-f1 on a keyword and then work through from there.Yes, someone did give me the answer that tKizer kindly offered. Alas as it has been some time since I came across the problem from before I had forgot! However I spend some amount of time searching these forums for my post from before which I beleive was some time last year. I used all manner of search words I could think of but could not find it. It might have helped if I could search for all posts by a given user without the required search text, but there you go.So I searched the forum, I searched the BOL in places I thought I should be looking, I have a bad memeory like many others in the human race, and no I do not expect people to keep answering the same question everytime I forget. But after exhausting my searching I chose to ask again.If my thread(s) irritate you feel free to ignore them, there is no rule that says you have to reply to any post and certainly no rule that states just because you have greater knowledge on a subject you have the right to be condescending.End of! |
 |
|
|
Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)
7020 Posts |
Posted - 2006-05-03 : 20:10:46
|
| I wasn't trying to be condescending, but since you prefer that I don't answer your questions, I won't.CODO ERGO SUM |
 |
|
|
|
|
|
|
|