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

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!

Related

BIRT xlsx export doesn't wrap cell contents

I'm working with BIRT reports (version 4.6.x) within Eclipse and I'm trying to export whole report into .xlsx. Rerport contains header with some data, image and table with results.
When I try SPUDSOFT xls or xlsx, I still encounter the same error.
Data in the table are correctly wrapped (if the column is too narrow, height of the line is increased and so on), however the table header (with column lablels) remains single line and you can't correctly read its contents.
I use whitespace wrapping Normal and I've tried to use dynamic text instead of standard label with wrap function (as it's used in datasets).
But the header row is still with no wrapping. It looks good on the web, but doesn't work in excel.
Have you encountered the same problem? How do I wrap the header line?
See attached report - it's only a draft, but how do I set the lines to wrap their content? Try exporting it to xlsx.
Test rptdesign sample

Unexpected line break when importing to SQL from SSIS

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","")))

SPSS v22 export to .emf causes encoding issues in the exported graphic

I'm using SPSS for a research project and I want to export the graphs to a vector graphic format to keep them clean and zoomable. The export to .emf causes my local characters like ä,ü,ö (german localisation) to render as ü or ö. In another thread I read that this is a bug of SPSS 21 so I switched to v22. Now on v22.0.0.1 I still have this issue when exporting as an emf-file. I tried using unicode as well as my country specific encoding in the settings but neither of these work and I get these strange symbols in the exported file.
Did I miss something or is there some kind of workaround for this?

Difficulty with filename and filemime when using Migrate module

I am using the Drupal 7 Migrate module to create a series of nodes from JPG and EPS files. I can get them to import just fine. But I notice that when I am done importing them if I look at the nodes it creates, none of the attached filefield and thumbnail files contain filename information.
Upon inspecting the file_managed table I see that both the filename and filemime fields are empty for ONLY the files that I attached via the migrate module. This also creates an issue with downloading the files.
Now I think the problem has to do with the fact that I am using "file_link" instead of "file_copy" as the file operation I specify. The problem is I am importing around 2TB (thats Terabytes) of image files. We had to put in a special request with Rackspace just to get access to that much disk space on our server. So I can't go around copying from one directory to the next because of space issues. So "file_link" seems like the obvious choice.
Now you probably want to see how I am doing this exactly, so here is the code snippet:
$jpg_arguments = MigrateFileFieldHandler::arguments(NULL,
'file_link', FILE_EXISTS_RENAME, 'en', array('source_field' => 'jpg_name'),
array('source_field' => 'jpg_filename'), array('source_field' => 'jpg_filename'));
$this->addFieldMapping('field_image', 'jpg_uri')
->arguments($jpg_arguments);
As you can see I am specifying no base path (just like the beer.inc example file does). I have set file_link, the language, and the source fields for the description, title, and alt.
It is able to generate thumbnails from the JPGs. But still missing those columns of data in the db table. I traced through the functions the best I could but I don't see what is causing this. I tried running the uri in the table through the functions that generate the filename and the filemime and they output just fine. It is like something is removing just those segments of data.
Does anyone have any idea what this could be? I am using the Drupal 7 Migrate module version 2.2. It is running on Drupal 7.8.
Thanks,
Patrick
Ok, so I have found the answer to yet another question of mine. This is actually an issue with the migrate module itself. The issue is documented here. I will be repealing this bounty (as soon as I figure out how).

Macros in SQL Server Management Studio

Is there any way to implement text editing macros in SSMS? I would, e.g. like to convert the the code as shown below, but with a key-press, not a long-winded regex search and replace.
This:
INSERT INTO [TABLE]
([fieldOne]
,[fieldTwo])
VALUES
(<fieldOne, datetime,>
,<fieldTwo, real(24,0))
Must become this:
INSERT INTO [TABLE]
([fieldOne]
,[fieldTwo])
VALUES
(#fieldOne
,#fieldTwo)
I know SSMS doesn't natively support this, but I also know that it is extensible, if undocumented, and there is also room for a totally external application that will take copied text, transform it, and paste it back, without having to open an editor, paste, edit, copy, and paste back to SSMS.
Editing the stored templates is not an option, as these templates are dynamically generated, and using Ctrl+Shift+M is not an option either, as I still have to type each parameter name, but without the convenience of copying and pasting in the query editor.
There is no SSMS solution! I am looking for some sort of external voodoo that can help me do this.
What about an AutoHotKey script?
Depending on the complexity of your templates, you could either
use AutoHotKey to play back the keystrokes
needed for the regex search and
replace, or
copy the template to
the clipboard and manipulate it
directly within AutoHotKey before
pasting it back.
I'm sure the first option will work. I've not tried the second.
This question gives an indication of how an AutoHotKey script can be written to listen for keyboard chords.
If you are using SSMS 2005 upwards it has in built support for templates. It isn't exactly full blown macro's, but non the less it is still pretty useful.
The syntax is exactly as you have shown in your first code snippet and you simply press Ctrl+Shift+M to bring up a dialog box that prompts you for the values to go into your bits enclosed in angle brackets.
SQL server generates script in this format if you right click on a table and select "Script Table as" then pick either the insert, update or delete option.
You can also create your own custom templates, or modify one of the existing built in ones (click on View -> Template explorer to get access to the other inbuilt templates).
There is a short article on MSDN that explains how to get started with templates.
Was looking for something else, but found this question. If you're still looking for something, try SSMS toolpack: http://www.ssmstoolspack.com/ It has macros and a bunch of other neat things. And it's free!
For SSMS 2016 you can use my Visual Commander extension. It supports macros recording/playback and custom C#/VB commands for editor text manipulations.
First code is template from old-good MS Query Analyzer. Shortcut to filling is Ctrl+M (but I'm not sure, maybe it is Ctrl+Shift+M).
There should be same feature in newer SSMS.
I usually copy the code into another editor (Notepad++, or Delphi /RAD Studio editor), do my macro stuff, and then paste it back into SSMS.

Resources