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 |
|
e.bar
Starting Member
25 Posts |
Posted - 2006-04-12 : 11:13:56
|
| I need to create a txt file based on a query results. Each row of the txt file must be like this:000039326000022013where:- 6 first positions with an user code (right justified, left zero filled);- 3 next positions with a fixed product code (326);- 9 last positions with amount (right justified, left zero filled and no decimal);Tks. |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2006-04-12 : 11:21:37
|
| right('000000' + convert(varchar(6),UserCode),6) + '326' + right('000000000' + convert(varchar(9),convert(int,amount)),9)==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
e.bar
Starting Member
25 Posts |
Posted - 2006-04-12 : 12:01:50
|
| Ooops, it worked, but I made a mistake: I need the decimal (cents) with no comma or point. |
 |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2006-04-12 : 12:08:10
|
| right('000000' + convert(varchar(6),UserCode),6) + '326' + right('000000000' + convert(varchar(9),replace(convert(decimal(7,2),amount),'.','')),9)Probably some brackets wrong there.==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
|
|
|
|
|