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 |
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2006-12-22 : 07:48:12
|
Lawrence writes "I have a transaction table that I need to export for our financial system to import. It has a lot of zero's and a lot of spaces in the requested file.Is there a way to do that and if there is how? I do have a copy of the requested file if you need to see it.Here is one line sample:EXP-XFER-DYNAMIC 061100002 2006 0415 CA50BIBOTH 2621 2006 0440 SR000 NONPERS 2621 000000000001350D000000000001350I 2006110720061130I know how to get the data and I know where, but I have no idea on how to get the spaces zero's and so on. Some help would be great!Thanks" |
|
snSQL
Master Smack Fu Yak Hacker
1837 Posts |
Posted - 2006-12-22 : 12:23:04
|
You'll need to give much more specific information like your table column structure and the exact output format required for each source column if you want an actual working example.But basically what you want to do is not hard, just use the various string functions to create the format that you need, look for "string functions" in Books Online.Here's a simaple example that pads with spaces to create a value with 15 charactersDECLARE @intValue intSET @intValue = 12345SELECT replicate('0', 15 - len(cast(@intValue AS varchar(10)))) + cast(@intValue AS varchar(10)) |
|
|
|
|
|