SQL Server Excel and Soft Returns

Many moons before reporting services existed, I was involved in writing a report architecture which was based upon SQL server and MS Excel.

In short sql queries were executed and data dumped into excel and then formatted via embedded macros.

In Excel a Soft Return is done by pressing ‘Alt + Enter’. In some cases you may return a 1:Many relationship as a single string and want to delimit it with a carriage return between each element.

To get this to work in Excel you need to use the Ascii code for {LF} which is Char(10).

So that way your comma delimited string can appear with newlines, and turn on wrap in the column and the data formats nicely in excel.

Probably not useful for anyone else, but I needed to do this again today and do you think I could remember the Ascii code….

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.