0

I am cleaning up a SQL script to replace escaped apostrophes \' with '' as it is in MySQL syntax and I need it to work in MSSQL but no matter what I try it doesn't work. How do you replace escaped apostrophes with two apostrophes in a file with Python?

2 Answers 2

1

It turns out replace("\'", "''") works. I'm sure I tried this but it must have been something else that stopped it from working initially.

Sign up to request clarification or add additional context in comments.

Comments

0

Create a store procedure the write the script to replace the special characters or regular expression like

`update table set column = REPLACE(column,"'",'"'); update table set column = REPLACE(column,"/","");

update table set column = REPLACE(column,"'",""");`

Reference : Remove special characters from a database field

And in the last call it by using Python script

EXEC PROC procedureName

1 Comment

Thanks, but it's the actual SQL insert statement itself that needs the escaped apostrophe replaced with '', so I can actually run it to begin with.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.