bcp and backspace (^H) delimiter - bcp

I need to parse a flat file which is containing backspace (^H) character delimiter between fields. I need to parse this file and insert into sql server 2005 tables.I tried to use bcp utility along with the format file but I wasn't able to specify the delimiter as backspace.
The default one is tab (\t). There are several other delimiters as well but none to specify backspace. Anyone has any ideas, please do help me.
Also I need to export data from sql server table to fixed length flat file.I tried to use non-xml format file, but always it asks for a delimiter.How can I create a flat file using bcp without any delimiter between the fields?
All above are character files.

This is an ugly workaround, but you could always find something that's not in the flat file, and replace everything in the flat file with that, then use that as the column terminator (using bcp -t that).

Sorry that I'm almost 11 years late on this, hopefully you've already solved your problem but you can use the hexadecimal representation of the backspace character 0x08 to parse your input file and properly delimit your fields which are separated with a backspace character.

Related

SQL How can I copy a csv file into a table with this delimiter problem?

I'm trying to copy a csv file into a table. The delimiter is ',' but the csv file has a field named 'Description' where it also uses ',' but not as a delimiter. As part of a text.
How could I copy the csv file into the Import table?
If the comma is always within the double quotes then it shouldn't be a problem.
If not, you have a corrupt CSV file. The simplest way is probably to parse your file prior to importing to fix the corruption.
The details of how exactly to parse will depend on the dataset. Which fields are optional? which fields are compulsory? How many commas can occur at most? That kind of information is crucial for writing a parsing script.

Japanese ANSI character in CSV file

I have a csv file generated from Japanese source system. The Japanese character is shown as given below ¬¼ˆã—Ê튔Ž®‰ïŽÐ ‘åã‰c‹ÆŠ. I have changed file type to UTF-8 and also ETL setting to incorporate that but that is working on new data only.
How can I change existing data in my table which shows characters like ‘åã‰c‹ÆŠ.
Is it possible to get original Japanese characters using SQL functions. I am using SQL Sever as database.
Thanks in advance.

Adding Urdu language text while exporting csv file from MSSQL Server

I have a column in my database containing some urdu language text. When I use bcp to export the data and opening the exported file in excel I am getting all the way question marks there.
What am I missing ?
Thanks in advance
You're using unicode urdu characters here. Use bcp -w instead for unicode characters.

How to create format files using bcp from flat files

I want to use a format file to help import a comma delimited file using bulk insert. I want to know how you generate format files from a flat file source. The microsoft guidance on this subjects makes it seem as though you can only generate a format file from a SQL table. But I want it to look at text file and tell me what the delimiters are in that file.
Surely this is possible.
Thanks
The format file can, and usually does include more than just delimiters. It also frequently includes column data types, which is why it can only be automatically generated from the Table or view the data is being retrieved from.
If you need to find the delimiters in a flat file, I'm sure there are a number of ways to create a script that could accomplish that, as well as creating a format file.

SSIS convert escaped character to asc(non printable characters)

I use SSIS to migrate some csv files (from UNIX) into SQL. one csv file contains data like:
ID,Name,Desc
1,12345\t,12345\177
If the schema for Name or Desc must be varchar(6), then the migration will fail due to the non printable characters are presented as \t, \177...
How can I convert the escaped characters to non printable characters in SSIS?
\t to Char(9)
\177 to Char(127)
Is there a better solution?
You should be able to use regular expressions regex.unescape to do this. I would suggest loading the assembly and doing it in SQL server using a temporary table, check this out http://msdn.microsoft.com/en-us/magazine/cc163473.aspx