Remove text qualifier in header only - ssis

I'm new to SSIS, but I've written a package that exports data from a SQL Server table to a CSV text file. I've been asked to remove the text qualifier (double quotes) from the header only. Can someone tell me if this is possible, and if so, how would I accomplish this? I can't find anything on removing the qualifier from the header and keeping it for the data.
I'm using SQL Server Data Tools 2015 to construct the package if that helps.

Related

Extra spaces in files and getting error to upload them in SSIS

My client stores daily files into a folder and after that I use a SSIS package to import these tables into the SQL database.
Today I come across with an issue, the files that they sent have spaces here:
The SSIS can not upload the files because of this space and in the SSIS package they put these dots.
Does anyone know if it is possible to solve this automatically or I need to inform them that they need to re-upload the files without the spaces?
Thanks
You can work with this...
Script component:
Row.ID_Auto = Row.ID_Auto.Trim().Trim('"');
You might want to consider adding a new int column as well.
Row.ID_IntConversion = int.Parse(Row.ID_Auto.Trim().Trim('"'));
First Trim cleans the white space, and second trim clears double quote.
I am pretty sure you can figure something out with a derived column as well.

SSIS Exporting to Flat File Destination (CSV) - Custom Property EscapeQualifier Not Working (Undocumented?)

Many questions have been asked on this topic, but I can't find anything specifically addressing what I see in Visual Studio 2017 (SSDT). A Custom Property named "EscapeQualifier" exists for a flat-file destination component in an SSIS project. Unfortunately, setting this to true doesn't seem to do anything.
Searching official documentation from MS doesn't even show the property existed.
On the surface, using this option seems to be a very elegant solution to the common issue of creating a "real" CSV file when the data being exported contains the double-quote character. If it worked as it seems it should, then it would double any double-quotes (or similarly escape whatever character you defined as your text-qualifier) for all quotable fields in the destination.
The solutions for "the CSV problem" that I've been able to find suggest modifying the specific data via transforms or at the data-retrieval level, but that's very impractical to do on each and every text-qualified data column.
To add insult to injury, I found a KB article from MS that suggests "exporting to CSV" is an official thing in SSDT.
KB4135137 - SSMS and SSDT do not escape double quotation marks when you export data as CSV
For example, you export a table into CSV format in a SQL Server Integration Services (SSIS) project.
This article suggests that the double-quotes not being escaped are a bug that has been fixed. Maybe it has, but only for the "Save results as..." option within SSMS. I still don't see any possible way to specify a true CSV export in an SSIS package, and this "EscapeQualifier" option gave me false hope.
Does this "EscapeQualifier" option ever do anything? If so, how do I get it to work? If not, is there another universal solution to the SSIS export to CSV issue?
Note: I created a pull request to add information about this property to Microsoft Docs.
As mentioned in the Flat File Destination properties, the EscapeQualifier property is used to:
When text qualifier is enabled, specifies whether the text qualifier in the data written to the destination file will be escaped or not
To test this property, I created a package the transfer data from a flat file to another one.
In the source flat file connection manager, the Text Qualifier is set to <none>, while in the destination flat file connection manager the text qualifier is set to ". The source flat file only contains the following value: my name is "hadi".
Is set the EscapeQualifier property as True in the flat file destination and execute the package. As shown in the screenshot below, the destination file contains the following value: "My name is ""hadi""" which means that this property worked as excepted.
Make sure that you have set a text qualifier in the flat file connection manager to ensure that this property will work as excepted.

Access Link Text Wizard - Syntax error in PARAMETER clause

I'm trying to link to a text file from the Access Link Text Wizard (as I've successfully done hundreds of times before) but this time I'm getting an error stating
Syntax error in PARAMETER clause.
No parameterized query is being used so I'm at a bit of a loss, I'm only trying to link to a text file.
In Access 2016 I go to the External Data tab and click Text File. I browse to my tab-delimited text file and select the Link to the data source creating a linked table option. As soon as I click OK it gives me the error above.
My text file is very simple with 2 columns and about 100 rows of data. This file is created from a Stored Procedure in SQL Server 2016 using BCP. If I manually create a text file with test data using the same format I don't get the error, which leads me to believe it may be some data in the file causing the error? I can't figure out how to attach text files to my question so any suggestions are welcome.
EDIT: I copied all data from the offending file into a new text file and it linked properly so it's not the data. I am often creating text files from a SQL Server Stored Procedure then linking to it from Access. This is the first time I've experienced this particular error.
EDIT2: I recreated a text file manually with the same data from the offending file and named it the same this time (Procedure Class Listing.txt) and I got the error. Is something wrong with this title???
EDIT3: Sorry for so many edits. I tried naming the file without the spaces and it links properly. I have linked to files with spaces in the name before so I don't understand.
FINAL EDIT: So it appears that a text file starting with the word "Procedure" followed by a space is giving me this error. I can remove all spaces (ProcedureClassListing.txt) and it works fine (which is the solution I'm going with).
So it appears that a file starting with the word "Procedure" followed by a space is giving me this error. I can remove all spaces (ProcedureClassListing.txt) and it works fine (which is the solution I'm going with).

Open Import Text Wizard in Access 2013 through VBA

I'm trying to open the Import Text Wizard as part of my code after it's ftp'd down a text file.
I don't have the metadata of the file as each file could be different, the only things they have in common is that they are pipe delimited with no text qualifier with a header row. No consistency in column type or number of columns.
Hence I don't think I can easily use docmd.transfertext as the specification would have to be different each time.
I don't mind pushing people down the manual route but if I look this up the instructions are to use Docmd.RunCommand acCmdImport. This appears to then be deprecated after Access 2007 as if I run it I get Run-time error 2002 saying the function or feature isn't installed in this version.
What I'm after is either:
A way to open the wizard
or
A way to import / link the text files without knowing the metadata ahead of the import.
The command is:
Docmd.RunCommand(acCmdImportAttachText)
That opens the wizard as if you called it from the band.

SSIS Handling a Flat File Missing a Text Qualifier

I'm currently designing as SSIS package to import some CSV files and needs to account for various error types. One of the errors is an incorrect or missing text qualifier.
I.E: "col1","col2","col3/,"col4"
The package is currently throwing the error "[ProductMaster CSV [66]] Error: The column delimiter for column "Column 2" was not found.".
Which is what I would expect to see in this situation.
Apparently getting the file initially sent in the correct format isn't an option at the moment.
I've tried changing the file to have no text qualifier, but this then falls over if there is a comma in a field so is not a viable solution.
Is there any way of handling this?
I use a third party tool to read csv files and it handles this type of situation. If you must do something on your own I would import the entire line to one column and then parse it with either a stored procedure or a script component.
There are plenty of solutions out there, some free and some with a minimal cost.
I have never found a way to handle this with SSIS connection managers 'out of the box'.
To solve this issue, look at your file format. Use text editor like Notepad++ and if your file is CR, make sure you don't use (") instead choose in the text qualifier and choose CR in the header row. This should work 100%