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 |
|
Jason_D
Starting Member
11 Posts |
Posted - 2002-07-05 : 16:20:37
|
Hey Dudes and DudettesI'm having some trouble with truncating some numbers.I would like to do the following:-12.123456 --> -12.12312.123456 --> 12.123123.123456 --> 123.123I've gotten this so far:number=left(round(number,3.3),6)but this only works for numbers in the form xx.xxxxxxIt's easy to do "if" statements, but I am actually performing this during the SELECT statement:eg. select number=left(round(number,3.3),6)peace |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2002-07-05 : 17:06:32
|
| have you tried converting to decimal?And you can use a case statement in a select.==========================================Cursors are useful if you don't know sql.Beer is not cold and it isn't fizzy.Edited by - nr on 07/05/2002 17:07:29 |
 |
|
|
Nazim
A custom title
1408 Posts |
Posted - 2002-07-06 : 08:27:24
|
| select abs(convert(decimal(16,2),round(@number,3.2)))-------------------------What lies behind you and what lies ahead of you are small matters compared to what lies within you.-Ralph Waldo Emerson |
 |
|
|
Jason_D
Starting Member
11 Posts |
Posted - 2002-07-08 : 10:04:23
|
| Thanks guysThe following worked for me. My numbers are in the format decimal (9.7)number=stuff(round(number, 3.3), len(number)-3, 4,'') |
 |
|
|
MakeYourDaddyProud
184 Posts |
Posted - 2002-07-08 : 10:17:53
|
| Take a look at CEILING and FLOOR T-SQL functions to further rearmour your knowledge, they might also help at some point...Daniel Small MIAPwww.danielsmall.com IT Factoring |
 |
|
|
|
|
|
|
|