Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
anderskd
Starting Member
25 Posts |
Posted - 2010-08-11 : 15:37:00
|
Hello, This might be an easy one, but I can't seem to find an answer.I'm trying to concatenate a numeric value with some padding to make a string that should include commas and periods. The example number value currently is: 1234I need it to display like this - with the commas and decimal points:****1,234.00I've been trying some different functions, but can't seem to get it to format the string correctly:SELECT RIGHT('*********' + RTRIM(CONVERT(CHAR(20), 1234)), 12)I would like the string value to be (ignoring the * padding for now):1,234.00Any ideas? |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2010-08-11 : 15:47:59
|
SELECT CONVERT(VARCHAR(30), CAST(1234 AS MONEY), 2) -- Or one of 0, 1, 2, 3. Read Books Online which is proper. N 56°04'39.26"E 12°55'05.63" |
 |
|
jackv
Master Smack Fu Yak Hacker
2179 Posts |
Posted - 2010-08-11 : 16:00:46
|
declare @num INTSET @num = 222222SELECT CONVERT(varchar(11),CONVERT(money,@num),1)Although the format side of things should be done on application sideJack Vamvas--------------------http://www.sqlserver-dba.com |
 |
|
anderskd
Starting Member
25 Posts |
Posted - 2010-08-11 : 16:07:19
|
That's exactly what I was looking for.Thanks for the quick solutions! |
 |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2010-08-13 : 11:03:13
|
quote: Originally posted by anderskd That's exactly what I was looking for.Thanks for the quick solutions!
Also as stated, if you use front end application, do this formation thereMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|
|