• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 222
  • Last Modified:

Numeric Output Format

Experts,
I'm trying to select a combination of text and numbers as below:
SELECT  N'      P_Index:   ' + convert(nvarchar,PriceIndex) + ' (' + convert(nvarchar,dbo.Client_Online_Indices.Change) + ')   '  AS Total

The problem is that i get a wrongly formatted output:
P_Index:  1.45448e+007

I need the numbers to look properly!
0
feesu
Asked:
feesu
  • 3
  • 3
1 Solution
 
patriktCommented:
Look for CONVERT help. There is third parameter whch specifies format.
0
 
feesuAuthor Commented:
Couldn't find it.
0
 
patriktCommented:
convert(nvarchar,str(PriceIndex,20,0),1)
0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

 
feesuAuthor Commented:
This worked, but insn't there a way to format those numbers?
0
 
patriktCommented:
No other way than specifiing number of decimal places.
Formating is normaly presentation layer function so SQL has no need to do this.
0
 
feesuAuthor Commented:
OK! Thanks alot.
0

Featured Post

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now