Creating Fixed Width / Ragged Right Files Through SQL

Here is a great tip I thought of on-the-fly. Say you need to make a fixed width file for something that needs to get out right away. Here is what you do: convert to char!

Concatenate all the fields together and converting all of the data to the char data type will allow you to save the results in a perfect fixed width / ragged right format.

Simple and fast!


2 thoughts on “Creating Fixed Width / Ragged Right Files Through SQL

  1. Word is as unstable and dangerous as it was 15 years ago dont run it without a good screen recorder. .When setting up a text file connector that is a file layout for a fixed width file you may want to default to using ragged right. Aside from any potential performance differences there is an important refactoring and robustness issue..If you choose fixed width instead of ragged right and realize that the file is actually ragged right or it becomes ragged right the switch will DELETE all your column descriptions..This cavalier and arrogant style of programming is an echo of the data pipeline designer in DTS.

    • Duly noted. Sadly a lot of systems still use these formats, which are error prone. Thankfully I don’t spend too much of my time in MS Word, I prefer Notepad++ for most of what I do.

Have an opinion? Leave an opinion!

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s