I am creating data sets to export to Microsoft Excel. There is one field in particular that is causing a lot of pain. The is "Posting Period". The Excel file is a CSV and will be used to upload to an ERP system. This system requires posting periods to be in the following format:
eg. Apr 2019 - in other words, three characters, a space then the year as a four digit numeric.
Well, as soon as this value is pasted into Excel from a results set in SSMS, it becomes Mar-19 and is now a date-type format! I have tried formatting the field in SQL as varchar or char but this makes no difference. To achieve what I want in Excel, you have to put a single apostrophe at the beginning. eg. 'Mar 2019. If you type that into Excel, the apostrophe disappears. Lovely. I have managed to get this exact value from SQL but when that is pasted in, hey presto! it becomes 'Mar 2019. What's going on???
Can anyone help me on this?