dbTalk Databases Forums  

ROUND or CAST Function?

microsoft.public.sqlserver.dts microsoft.public.sqlserver.dts


Discuss ROUND or CAST Function? in the microsoft.public.sqlserver.dts forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
don larry
 
Posts: n/a

Default ROUND or CAST Function? - 10-03-2003 , 03:14 PM






Greetings,

Very simple guys:

X = 2.000
X = 2.001
X = 2.356
X = 2.899

1st X should return 2, all others should return 3.
What is the dynamic function to make this happen?

Thanks, Don


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Reply With Quote
  #2  
Old   
Edgardo Valdez
 
Posts: n/a

Default ROUND or CAST Function? - 10-03-2003 , 04:34 PM






You can probably use the following example:

create table ##round
(input decimal(10,3))

insert into ##round
values (2.000)
insert into ##round
values (2.001)
insert into ##round
values (2.356)
insert into ##round
values (2.899)

select Input, case ((convert(decimal(10,3), (cast(Input as
int)+1)))-Input) when 1.000 then ROUND(Input, 0) else (cast
(Input as int)+1) end Output
from ##round

drop table ##round


Edgardo Valdez
MCSD, MCDBA, MCSE, MCP+I
http://www.edgardovaldez.us/

Quote:
-----Original Message-----
Greetings,

Very simple guys:

X = 2.000
X = 2.001
X = 2.356
X = 2.899

1st X should return 2, all others should return 3.
What is the dynamic function to make this happen?

Thanks, Don


*** Sent via Developersdex http://www.developersdex.com
***
Don't just participate in USENET...get rewarded for it!
.


Reply With Quote
  #3  
Old   
Sue Hoegemeier
 
Posts: n/a

Default Re: ROUND or CAST Function? - 10-04-2003 , 07:38 AM



Take a look at the Ceiling function - it returns the
smallest integer equal to or greater than the value.
You would just use:
SELECT CEILING(X)
FROM YourTable

-Sue

On Fri, 03 Oct 2003 13:14:50 -0700, don larry
<donlarry17 (AT) hotmail (DOT) com> wrote:

Quote:
Greetings,

Very simple guys:

X = 2.000
X = 2.001
X = 2.356
X = 2.899

1st X should return 2, all others should return 3.
What is the dynamic function to make this happen?

Thanks, Don


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


Reply With Quote
  #4  
Old   
don larry
 
Posts: n/a

Default Re: ROUND or CAST Function? - 10-06-2003 , 02:50 PM



Thank you so much Edgardo , Sue..

The ceiling function is exactly what i wanted!

Don


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.