Click here to Skip to main content
15,913,836 members
Home / Discussions / Database
   

Database

 
GeneralRe: BULK INSERT into SQL Server from CSV with apostrophes instead the strings Pin
T210230-Mar-10 23:22
T210230-Mar-10 23:22 
AnswerRe: BULK INSERT into SQL Server from CSV with apostrophes instead the strings Pin
R. Giskard Reventlov30-Mar-10 23:11
R. Giskard Reventlov30-Mar-10 23:11 
Firstly, why do you need to remove the apostrophes? Are they not part of the text you are importing or are they superfluous characters that shouldn't have been there?

Either way you might consider opening the csv file in code and then either doubling the apostrophes or removing them, something like (and this is a very simplistic example):

string filePath = "full_path_to_the_csv_file";
string text = File.ReadAllText(filePath);

// Either:
text = text.Replace("'", "''");
// or
text = text.Replace("'", string.Empty);

File.WriteAllText(filePath, text);


You'll need to adjust to suit but it should get you started.
me, me, me

"The dinosaurs became extinct because they didn't have a space program. And if we become extinct because we don't have a space program, it'll serve us right!"
Larry Niven

GeneralRe: BULK INSERT into SQL Server from CSV with apostrophes instead the strings Pin
T210230-Mar-10 23:28
T210230-Mar-10 23:28 
GeneralRe: BULK INSERT into SQL Server from CSV with apostrophes instead the strings Pin
Mycroft Holmes31-Mar-10 1:27
professionalMycroft Holmes31-Mar-10 1:27 
GeneralRe: BULK INSERT into SQL Server from CSV with apostrophes instead the strings Pin
R. Giskard Reventlov31-Mar-10 5:09
R. Giskard Reventlov31-Mar-10 5:09 
GeneralRe: BULK INSERT into SQL Server from CSV with apostrophes instead the strings Pin
T21021-Apr-10 3:25
T21021-Apr-10 3:25 
GeneralRe: BULK INSERT into SQL Server from CSV with apostrophes instead the strings Pin
R. Giskard Reventlov1-Apr-10 4:04
R. Giskard Reventlov1-Apr-10 4:04 
GeneralRe: BULK INSERT into SQL Server from CSV with apostrophes instead the strings [modified] Pin
T210231-Mar-10 19:07
T210231-Mar-10 19:07 
QuestionDeducting data vs saving it explicitly Pin
Alivemau530-Mar-10 11:11
Alivemau530-Mar-10 11:11 
AnswerRe: Deducting data vs saving it explicitly Pin
PIEBALDconsult30-Mar-10 12:13
mvePIEBALDconsult30-Mar-10 12:13 
AnswerRe: Deducting data vs saving it explicitly Pin
Garth J Lancaster30-Mar-10 15:51
professionalGarth J Lancaster30-Mar-10 15:51 
AnswerRe: Deducting data vs saving it explicitly Pin
PIEBALDconsult30-Mar-10 17:48
mvePIEBALDconsult30-Mar-10 17:48 
AnswerRe: Deducting data vs saving it explicitly Pin
Eddy Vluggen31-Mar-10 0:36
professionalEddy Vluggen31-Mar-10 0:36 
Questionlogin Pin
farokhian30-Mar-10 9:44
farokhian30-Mar-10 9:44 
AnswerRe: login Pin
netJP12L30-Mar-10 10:13
netJP12L30-Mar-10 10:13 
GeneralRe: login Pin
farokhian30-Mar-10 10:42
farokhian30-Mar-10 10:42 
AnswerRe: login Pin
Don Burton30-Mar-10 10:21
Don Burton30-Mar-10 10:21 
Questiontable join Pin
netJP12L30-Mar-10 8:15
netJP12L30-Mar-10 8:15 
AnswerRe: table join Pin
Mycroft Holmes30-Mar-10 22:56
professionalMycroft Holmes30-Mar-10 22:56 
QuestionHelp with T-SQL Statement?? Pin
ostinoh30-Mar-10 5:02
ostinoh30-Mar-10 5:02 
AnswerRe: Help with T-SQL Statement?? Pin
Don Burton30-Mar-10 10:23
Don Burton30-Mar-10 10:23 
GeneralRe: Help with T-SQL Statement?? Pin
ostinoh30-Mar-10 15:21
ostinoh30-Mar-10 15:21 
AnswerRe: Help with T-SQL Statement?? Pin
Mycroft Holmes30-Mar-10 23:03
professionalMycroft Holmes30-Mar-10 23:03 
QuestionDynamic stored procedure returns error and can't find culprit Pin
DeepToot30-Mar-10 3:52
DeepToot30-Mar-10 3:52 
AnswerRe: Dynamic stored procedure returns error and can't find culprit Pin
R. Giskard Reventlov30-Mar-10 4:09
R. Giskard Reventlov30-Mar-10 4:09 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.