Hi. This looks like a common problem that I need an uncommon solution to.
I have a legacy program that takes a tab delimited file and imports it into an SQL table. The rules of the import is that the memofield cannot contain embedded quotes but can contain carriage control characters. The field is surrounded by double-quotes. All other fields are separated by tabs but have no quotes.
The file needs to look something like:
field1 <tab> field2 <tab> "field 3 is a memofield with lots of line feeds"
I need a mechanism that can deliver a tab delimited flat file with only the memofield enclosed in quotes. When I installed the SQL Management Console for an SQL Express client, I see that I have a tool called "import and export data (32-bit)". I've tried playing with this but haven't had any luck getting the format I want. I noticed that if I use the text qualifier, it puts quotes around EVERYTHING, even signed integers <bad idea!> I've also tried with the SQL select query and it looks like there's extra linefeeds or something. All I know is that even Excel is treating the field as multiple records, not as a single field.
My query is
SELECT EQUIPNO, EQUIPNAME, '"' + cast(EQUIPMENTMEMO.DESFILE as varchar(max))+ '"' as desfile, VENDORS.VENCODE, VENDORS.VENNAME, CUSTOMER.CUSTOMERNO,
CUSTOMER.CUSTOMERNAME
FROM EQUIPMENT
LEFT OUTER JOIN EQUIPMENTMEMO ON EQUIPMENT.EQUIPID = EQUIPMENTMEMO.EQUIPMENTID
LEFT OUTER JOIN VENDORS ON EQUIPMENT.VENDORID = VENDORS.VENDORID
LEFT OUTER JOIN CUSTOMER ON EQUIPMENT.CUSTOMERID = CUSTOMER.CUSTOMERID
ORDER BY EQUIPNO
This is on a SQL2008 Express database. Any workable solution can't involve full SQL tools. I would prefer to do this without writting an application, if possible. Any suggestions on getting this exported?