Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

format of decimal Expand / Collapse
Author
Message
Posted Wednesday, September 04, 2013 1:34 PM
SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Tuesday, April 15, 2014 9:54 AM
Points: 1,720, Visits: 3,063
I have a SSIS package, of attendance data. most of them is a whole number like absent days 5 days, or 100 days in a semester. But some of the elementarys we count by half days, so they may have total absent days like 10.5 days.

Because in the databsae the data type is a decimal(4,1), when I export to a flat file, I would like the whole number still shows whole number, like 20 days, I would like it shows 20 instead of 20.0. but still want those with half days like 10.5 shows like that format.

How can I do a conversion?

Thanks
Post #1491511
Posted Wednesday, September 04, 2013 3:24 PM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: General Forum Members
Last Login: Yesterday @ 10:06 PM
Points: 35,978, Visits: 30,269
sqlfriends (9/4/2013)
I have a SSIS package, of attendance data. most of them is a whole number like absent days 5 days, or 100 days in a semester. But some of the elementarys we count by half days, so they may have total absent days like 10.5 days.

Because in the databsae the data type is a decimal(4,1), when I export to a flat file, I would like the whole number still shows whole number, like 20 days, I would like it shows 20 instead of 20.0. but still want those with half days like 10.5 shows like that format.

How can I do a conversion?

Thanks


I guess I have to ask.... why do you want to build in an inconsistancy here?


--Jeff Moden
"RBAR is pronounced "ree-bar" and is a "Modenism" for "Row-By-Agonizing-Row".

First step towards the paradigm shift of writing Set Based code:
Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column."

"Change is inevitable. Change for the better is not." -- 04 August 2013
(play on words) "Just because you CAN do something in T-SQL, doesn't mean you SHOULDN'T." --22 Aug 2013

Helpful Links:
How to post code problems
How to post performance problems
Post #1491550
Posted Wednesday, September 04, 2013 3:49 PM
SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Tuesday, April 15, 2014 9:54 AM
Points: 1,720, Visits: 3,063
You are right, although I have some reason but I think maybe I should keep it consistent.

A derived question, U use dt_numeric precision 38, scale 1, when I export I expect 0.5. but why it shows
.5 the leading 0 is trimmed off.

Any idea?

Thanks
Post #1491560
Posted Wednesday, September 04, 2013 11:39 PM


SSCarpal Tunnel

SSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal Tunnel

Group: General Forum Members
Last Login: Yesterday @ 4:25 AM
Points: 4,828, Visits: 11,184
sqlfriends (9/4/2013)
You are right, although I have some reason but I think maybe I should keep it consistent.

A derived question, U use dt_numeric precision 38, scale 1, when I export I expect 0.5. but why it shows
.5 the leading 0 is trimmed off.

Any idea?

Thanks


0.5, 00.5, .5 and .50000 are all the same, numerically - the leading and trailing zeros are insignificant. Why does it matter?



Help us to help you. For better, quicker and more-focused answers to your questions, consider following the advice in this link.

When you ask a question (and please do ask a question: "My T-SQL does not work" just doesn't cut it), please provide enough information for us to understand its context.
Post #1491625
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse