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 |
|
rbohaty
Yak Posting Veteran
71 Posts |
Posted - 2004-09-22 : 18:03:17
|
| I have column (balance) which is a money data type. I am trying to pad the number with spaces so if the number is 34.56 the resulting would be a decimal ^^^^^34.56. The following sql is what I was planning on using but I get a message that I have to use convert. Any suggestions?SELECT LEFT(SPACE(10 - LEN(Balance)), 10) + CAST(Balance AS varchar(10)) AS Balance, LEFT(StudentID + SPACE(16), 25) AS StudentIDFROM dbo.Cox_FACTS |
|
|
jsmith8858
Dr. Cross Join
7423 Posts |
Posted - 2004-09-22 : 19:06:53
|
| don't format your data with SQL, do it at the presentation layer.- Jeff |
 |
|
|
clarkbaker1964
Constraint Violating Yak Guru
428 Posts |
Posted - 2004-09-22 : 20:00:28
|
| You have the syntax correct for the Balance follow you same logic for StudentID... Check to see if the StudentID is a Char or Varchar, in your example it is assumed.You may also want to convert to something longer than 10... I validated with our PL table and it came accross some numbers that overflowed, although our system was designed using decimal (not my decision) I am guessing you are trying to create data dumps for legacy system in fixed file format.You may be better off creating a DTS to export to fixed length then have the programmer modify the copy book accordingly... My preference for that environment is tab delimited because a tab char does not exist their... rambling sorry. ;-)Surf On Dude! |
 |
|
|
|
|
|