mopaware.blogg.se

Import csv to sql server 2016 double quotes
Import csv to sql server 2016 double quotes









Script that I had tried earlier but it didn't produce the correct output. I had used the 'here-string' earlier and didn't get the correct results and after seeing your solution I see it has to do with the way the content is prepped and exported. Import-csv C:\temp\test1.csv -Delimiter '|' | ft -Wrap If you can generate here-strings from your data source? would only map's the text "before" this double quote."Īnd a PSObject -Property Carter"' 'Description'='"PowerShell maps this whole text to the description column."'} "Bob Segel" "PowerShell would only map's the text "before" this double quote." "John Carter" "PowerShell maps this whole text to the description column."

import csv to sql server 2016 double quotes

Import-csv C:\temp\test1.csv -Delimiter '|' | ft -AutoSize $temp | export-csv 'c:\temp\test1.csv' -Delimiter '|' -NoTypeInformation $temp+=New-Object PSObject -Property Segel"' 'Description'=$herestring} Generating 'here' strings appears could be a solution: would only map's the text "before" this double PSObject -Property Carter"' 'Description'='"PowerShell maps this whole text to the description column."'} Until I find a better alternative, I am thinking to export all the data as XML and use 'CDATA' to export the values for the 'description' column. Any other out of the box PowerShell functionality that i can leverage? Solution I am thinking of:: So while importing, PowerShell treats all the text in the 'description' column as a single string (including While exporting, is there a way to use 'here-string' like symbol that can be inserted infront of the text for the 'descrition' column. I need to keep the original formating intact.

import csv to sql server 2016 double quotes

While exporting, I do not want to manipulate the description data, like replace double quotes with single quote.

import csv to sql server 2016 double quotes import csv to sql server 2016 double quotes

But I need to find a way to map all of the text (including quotes and post double quotes) to the column 'description'. I understand that, while reading column value, PowerShell would treat double quotes as the end of string. In PowerShell, i run the follwoing command: Import-csv -Path "c:\\sample-input.csv" -Delimiter "|" "Bob Segel"| "PowerShell would only map the text "before" this double quote." "John Carter"|"PowerShell maps this whole text to the description column." Note, the 'description' column can contain any rich html syntax (, class="some-name", qouble/single quotes, carriage returnd, end of line, etc.): Via PowerShell, I export the follwoing two column 'csv' file.











Import csv to sql server 2016 double quotes