Unexpected line break when importing to SQL from SSIS - sql-server

I when I import a pipe delimited .txt file I receive from a client every once in a while, one of my records will import into the raw table with a line break in the tuple. But when I look at the .txt file I see neither {CR}{LF} or {LF}.
I can't figure out why this is happening. Has anyone else ever experienced this?

I have had similar issues. I ended up stripping out any \n or \r escape characters from string data after it had already come into the data flow using either a derived column or a custom script component. That fixed the problem for me. It helps to enable the data viewer to see what the data looks like as you are debugging.

I have had issues like this before and found that in some cases SSIS could only recognize tabs, linefeeds, & carriage returns using the hexadecimal format:
x0009 - tab
x000A - feed
x000D - return
Try using something like this in your derived column:
(DT_STR,50,1252)TRIM(LOWER(REPLACE(REPLACE(REPLACE( *{your_column}*,"\x0009",""),"\x000A",""),"\x000D","")))

Related

Remove extra brackets from JSON call in Integromat

I am running a HTTP call to bring back data in JSON format but this is bringing through an extra set of square brackets that is causing issues when i am trying to recognise the array. See screen shots.
I can remove the extra set manually in a JSON editor but need to try and find a way of doing this automatically as part of my call.
I am running the call through Integromat and have looked at using Regex but couldn't find the correct code combinations.
Any help or advise much appreciated.
You can use the replace function and insert the brackets that need to be found using regex pattern making sure you denote the bracket at the starting position and the bracket at the end of the string to be replaced with emptystring
Don't check "Parse Response" in HTTP Request module.
That way Data will be returned as long text
Use "Text Parser"'s "Replace", look for ^[|]$ and replace it with emptystring. Make sure you check "Global Match", otherwise it will only do to the first match only=[
3.Then just Parse Json from parsed(replaced) text
I think this article will help.
https://medium.com/#petr.hnilica/json-in-integromat-how-to-create-an-array-from-collections-with-the-same-structure-2991b985e03e

How do you import from CSV into SQL Server with a double text qualifier?

I have a problem with a SQL import from a CSV file that contains a text qualifier = "¬¬" i.e. only the part between the inverted commas. When I use the SQL Server Management Studio import tool I set the following:
The preview (all looks good - the way I would like it to import):
The output after the import (the problem):
This is what it replaces the text qualifier with: "¬¬"
I would appreciate any ideas on how to correct this issue thanks.
It seems that SSMS does not like the "¬¬" text qualifier for reasons unknown (perhaps relating to the encoding standard) and I found it easier to find and replace the qualifier with "^^^" using Notepad++. After importing the files again, the new qualifier worked without any further issues.
--Update--
Not sure why this did not seem as obvious before however using the odd output "¬¬" as the text qualifier solved this problem even better! Bear in mind that the preview text output using the import wizard will appear as being incorrect however the final output reflects correctly!

Add blank line between two lines of text in webcal event's description

How to add blank line between two lines of text in webcal event's description? This \n\n doesn't work.
It might help if you would provide a full iCalendar stream but, assuming you encoded them correctly, using "\n" is the only way to express intentional line break. Did you try to display your event using different clients ?

Can you concatenate RTF in a Crystal Reports formula Field

I'm currently building an application that generates a separate letter for each user in the dataset. The letter contents are managed through a vb.net application and their RTF format saved to a database. When the letter is created, all the content is pulled from the database to form the letter using vb.net logic.
Once compiled it was sent as a parameter to Crystal. This worked great, setting the field text interpretation to RTF allowed proper RTF viewing.
The client has decided that they would instead like to make changes to the logic (if statements that compile the text) within Crystal.
So what I did was create a blank dataset with a bunch of columns and filled those columns with the RTF (Ordered by ID so the values will never change unless a paragraph is deleted and there is no option for this). This would allow me to build an RTF string by going {table.1} + {table.2} etc...
This is where the problem is. When building an RTF string in a Formula (Using + or &) it only displays the first RTF entry. If I switch the formula to no interpretation, I can see the RTF for the entries written out with all their content so I know it’s there. I also manually combined the RTF in the formula field and had the same issue.
StringVar output;
output := output & "{\rtf1\ansi\ansicpg1252\deff0{\fonttbl{\f0\fnil\fcharset0 Times New Roman;}}\viewkind4\uc1\pard\lang1033\f0\fs23 this is a first test }";
output := output & "{\rtf1\ansi\ansicpg1252\deff0{\fonttbl{\f0\fnil\fcharset0 Times New Roman;}}\viewkind4\uc1\pard\lang1033\f0\fs23 this is a second test \par\par}";
Output
At this point I am unsure if there is a way around this other than moving all the text to separate Formula fields within crystal itself and then combine. This would mean if they wanted to change text it would have to be done within crystal. I would rather not go this route so I’m looking for opinions and suggestions.
Crystal does support RTF however it needs to be fully formed within the first occurance of an RTF entry. In my question it shows two separate COMPLETE RTF entries. As the entries all have the RTF ID tags this will not be possible. The same issue would occur if you copied the above text into a text editor and saved it as RTF. You would only get the first line. This doesnt explain why it works as a parameter and not a formula but its likely how each are evaluated and the later (parameter could loose support in the future).
To Properly pass RTF to crystal you will need to two Rich text box objects. One being a temp box and the other being the builder box and only selecting the formatted text, not the entire RTF content. An example of this can be found at:
http://moneybaron.org/2011/08/23/vb-net-merge-rtf-documents/
Aside from some hacks such as removing the closing brace from the RTF string or rebuilding the RTF table are also avaliable however removing the brace could lead to an unsupported configuration and rebuilding can get messy really quick.
Hope this helps!!

Dealing with newline character in database reports

Newbie question here.
I have a web form with a text area and naturally users will enter newline characters also. I am storing this form to a table in the DB. I also have to create a report from this. So I dump the table to text and am trying to parse it. The delimiters for me between multiple records is a new line character. But the new line character in the text area is throwing my script off.
I am sure someone must have run into this before. Can you suggest me ideas as to how to deal with this?
I tried having the text from the text area in double quotes but that will complicate my parsing logic. I was wondering if there is an easier way to deal with this.
I think the simple answer is some form of escaping.
You could do some find/replace in the SQL, such as REPLACE(thetext, '\n', '\\n'), or if the newlines are not important, you could do REPLACE(thetext, '\n', ' ')
Recently ran into the same issue. Your best best is to replace the newline characters during the data dump (or before the data gets to your database) with something else. I opted for something like // or <br> so that I can recover the new lines later.
I was trying to build one forum. The problem was when some user enters HTML. It would get translated when you display his post. And I was not able to move to next line when displaying his post. This might help you. I'm using PHP by the way.
$pattern = array('/</','/>/','/\n/');
$replace = array('<','>','<br>');
$post = preg_replace($pattern,$replace,$post);

Resources