Link to home
Start Free TrialLog in
Avatar of Jeff S
Jeff SFlag for United States of America

asked on

Formatting a field for a fixed length Flat File

I need to format a Flat File Fixed Length report for a client. In it they have allocated 12 characters for the patients phone number. In the file output, I need to format the phone exactly like this:

555/444-3333

I would like to know what would be the best way to right this value? I need to account for NULLs and if there is a NULL I need 12 blank spaces.

My field name is pp.Phone1
SOLUTION
Avatar of Bryan Butler
Bryan Butler
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
This assumes the number from the DB is always ###-###-####

If it is different, like (###)###-###, then this will need a little modification.  The key is that is always the same format, otherwise this won't work.
Shoot, that won't work now that I think about it as it's always going to be adding "/" and "+" to the inside query, which makes it never null.  If it is null, this will still return "/+" i believe.  Sorry about that.  Let me see what I can figure.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I think radceasar has it.  You're going to have to script something.  Can you use T-SQL?  
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Jeff S

ASKER

I want the two individuals get the points as they deserve and helped me. My solution was the one that worked, however they assisted to get me to that point. Please make sure they are awarded the points please.
Avatar of Jeff S

ASKER

Thanks for the help and getting me to my final answer.