Replace my quotes with brackets

I have an SQL database, I can export through php MyAdmin… but I needed to replace my quotes with brackets. Once I figured this out, I found the find and replace function in VisualStudio2015… unfortunately there’s no distinction between the opening and closing quotes. I can convert the tables manually… on the keyboard, but changing all of the entries over the last two years would require going over approximately 12,000 lines. So now I’m thinking my best bet might be to find a similar tutorial for importing XML or an Excel or CVS… or is there an option in MyAdmin to change the slant of my closing quote that I’m unaware of?

maybe I’m overlooking something I could do with a regular expression in the find and replace… '***' = [***]?

It has been a while, but does your version of phpMyAdmin have a section titled Format-specific options when exporting?

Look to see if there is a format for MSSQL, it may be under Database system or older MySQL server to maximize output compatibility with:

I have played around with a few export options, all with the same one size fits both sides solution.

So the issue is the quotes around the field and table names right? What if you uncheck that box under Structure?

Also, can you confirm that the quotes are ` (backtick) and not ’ (single quote)?

And if you could give me a line or two to work with, change the table names or anything else that may be “sensitive”, I can get you a regex find/replace that “should” work.

yes, they look like a backtick… and even if I can turn them off, won’t I have to still add the brackets. I can change the tables manually and that gives me a place to start scaffolding some CRUD, but I’d eventually like to import all of the historical entries. So I can work around the tables to get started, but would eventually like to import everything.

No. Brackets are only necessary when the column/table name matches a reserved word in SQL Server, so your number of errors should reduce greatly by turning them off.

SQL Server flat out does not allow backticks to surround table/field names, which is why it is complaining a lot right now.

You can use the Parse feature to validate the script without backticks to see how many column names/table names are matching reserved words.

Also, here is a quick idea of what would need to be done to do a find/replace (if you still want to go that way)

1 Like

generate your exported sql without backticks or brackets

that way, you won’t need the brackets except for problematic identifiers (i.e. those that contain special characters or spaces or are reserved words)

you will find the problematic identifiers quite easily… then fix them manually by adding brackets only where needed (or change the identifier to non-problematic)

1 Like

Thank you, that has made a huge difference. When I ran the parser over it, the only thing it doesn’t like now is the views. I’ve tried moving them to the top… but it still tells me they should be first, which is a little confusing, should I just take them out?

Msg 111, Level 15, State 1, Line 2396
‘CREATE VIEW’ must be the first statement in a query batch.
Msg 111, Level 15, State 1, Line 2509
‘CREATE VIEW’ must be the first statement in a query batch.
Msg 111, Level 15, State 1, Line 4783
‘CREATE VIEW’ must be the first statement in a query batch.

I think that means you need to have them in their own batch, meaning immediately following CREATE VIEW there should be a line with GO signifying a new batch is starting.

1 Like

Thank you so much, nothing more educational than finding the right questions!

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.