Showing posts with label retrieved. Show all posts
Showing posts with label retrieved. Show all posts

Friday, March 9, 2012

Format using SQL server

I'm new to SQL server. My question here is how can I format the data that is retrieved as a result of SELECT.

Similar defining the column format in SQL Plus. For some reason SQL Server puts in extra spaces between the data fields in the .dat file.

If you have additional trainling spaces, it seems that you specified a fixed character length instead of a variable. THe data won′t be chopped until you will specify it either in the table structure or within the Select statement while pumpoing the data out of the database (CONVERT).

HTH, jens Suessmeyer.

http://www.sqlserver2005.de

|||This is not with the data. Say if I have 2 fields Field 1 and Field 2. Field 1 is 12 char and field 2 is 2 char. Instead of putting Field 1 as 12 char it puts 15 char for Field 1 and for Field 2 it puts 4 char. I want to remove those extra spaces. I would appreciate any help.

Friday, February 24, 2012

Format Decimal number conditionally

My 'Hour' Fields are retrieved from stored procedure always with 1 decimal
place.
(ie: 2.0 hours, 3.5 hours)
I wish to display, (ie: 2, 3.5 respectively), the first value (2.0) without
the ".0".
So far I have this solution:
=IIF(Abs(Fields!Hours.Value) < Fields!Hours.Value, Fields!Hours.Value ,
Abs(Fields!Hours.Value) )
Is there a better solution? thanks!I found an even simpler solution:
I changed the Custom Format of my table cell to:
=Format(Cdbl(Fields!Hours.Value))
"SQT" wrote:
> My 'Hour' Fields are retrieved from stored procedure always with 1 decimal
> place.
> (ie: 2.0 hours, 3.5 hours)
> I wish to display, (ie: 2, 3.5 respectively), the first value (2.0) without
> the ".0".
> So far I have this solution:
> =IIF(Abs(Fields!Hours.Value) < Fields!Hours.Value, Fields!Hours.Value ,
> Abs(Fields!Hours.Value) )
> Is there a better solution? thanks!
>|||Apology.
Do not use the Custom Format.
Change the Text Value Property to, ie: =Format(Cdbl(Fields!Hours.Value))
"SQT" wrote:
> I found an even simpler solution:
> I changed the Custom Format of my table cell to:
> =Format(Cdbl(Fields!Hours.Value))
>
> "SQT" wrote:
> >
> > My 'Hour' Fields are retrieved from stored procedure always with 1 decimal
> > place.
> > (ie: 2.0 hours, 3.5 hours)
> >
> > I wish to display, (ie: 2, 3.5 respectively), the first value (2.0) without
> > the ".0".
> > So far I have this solution:
> > =IIF(Abs(Fields!Hours.Value) < Fields!Hours.Value, Fields!Hours.Value ,
> > Abs(Fields!Hours.Value) )
> >
> > Is there a better solution? thanks!
> >