Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

formatting data 1

Status
Not open for further replies.

myvision69

Programmer
Feb 3, 2006
18
US
i have a decimal number stored but i want to display the whole number only with three digits and no decimal places.

how can i do that in SQL?

Thanks
 
SQL has a round function, or you could convert it to another decimal(but with a different precision).

Declare @Temp Decimal(10,5)

Set @Temp = 123.75678

Select @Temp, Round(@Temp, 0), Convert(decimal(10,0), @Temp)

-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 

e.g. 78.00 needs to be displayed as 078
1.00 needs to be dispayed as 001
150.00 needs to be displayed as 150

How can I accomplish that?
 
If you have to...

See CONVERT() and ROUND() functions in Books Online.

------
[small]select stuff(stuff(replicate('<P> <B> ', 14), 109, 0, '<.'), 112, 0, '/')[/small]
[banghead]
 
Quick & dirty trick:
Code:
select right(convert(decimal(4, 0), 1000 + yourvaluehere), 3)

------
[small]select stuff(stuff(replicate('<P> <B> ', 14), 109, 0, '<.'), 112, 0, '/')[/small]
[banghead]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top