Forcing Text Values in a .CSV File Using the SQL Q

Demonstrates forcing text values in a .CSV file using the SQL Q

Note: In order for this sample task to work properly, please create a folder in your C:\ drive named SQL Query Test and copy the attached SampleCSVFile2.csv file into it.

When running a task using the 'SQL Query' action to query a .CSV file, the data displayed may not match the original data in the .CSV file. If you run the attached sample task, a message box will appear displaying the following information:

Frank
1

Instead of:

Frank
0001

This problem is solved by using a second file called Schema.ini". More details regarding Schema.ini can be found in the following msdn.microsoft.com site. It is advisable to read the article in it's entirety to become familiar with the flexibility of the Schema.ini file. The link is provided below:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/ht...

For this example, only a few things are needed inside the Schema.ini file. Create a text file called Schema.ini and place it inside the "C:\SQL Query test" folder. It is very important that the file have the name Schema.ini and be inside the same folder as the .CSV file. Add the following text to the Schema.ini file:

[SampleCSVFile2.csv]
Format=CSVDelimited
ColNameHeader=True
MaxScanRows=0
Col2=Number Text

Thereafter, save the file. When running the same task again, you will notice that the Message Box correctly displays the data as it is contained in the original .CSV file.

Task Category:

SQL