Sunday, March 11, 2012

export to table fixed filed size

Hello I need to export my table fixed filed size by making numbers 15 characters right alignment and strings 20 characters left alignment.

You could either use the BCP utility or a SELECT statement if your table is small. Your SELECT statement would look something like this:

SELECTCONVERT(char(15),col1) ,CONVERT(char15,col2)...FROM yourtable
|||

Thanks for the reply, how do I arrange alignment, numbers to right, strings to left?

|||

Perhaps something like this:

SELECT space(15-len(NumericVal)) +convert(varchar,NumericVal),CONVERT(char(20), StringVal)FROM yourtable

No comments:

Post a Comment