Joker chars

kalvaro's profile image kalvaro posted 12 years ago in General Permalink
Anse:

I've just read this in r4403:

MSSQL wants single quotes escaped with a second single quote, not with a backslash. No clue how to escape joker chars in a WHERE clause.

Not sure if you referred to the ESCAPE clause:

http://msdn.microsoft.com/en-us/library/ms179859.aspx
ansgar's profile image ansgar posted 12 years ago Permalink
Ah... thanks. I found details about the ESCAPE clause here, but I supposed this applies to a whole WHERE clause without a LIKE, and got an SQL error when testing that. In fact the ESCAPE syntax seems only valid for a LIKE clause. In that case I have an idea how to fix that - appending the ESCAPE clause to the two or three places where HeidiSQL has LIKE clauses.
ansgar's profile image ansgar posted 12 years ago Permalink
Exactly what I think here...
kalvaro's profile image kalvaro posted 12 years ago Permalink
This is all about searching for literal _ or % characters with the LIKE operator (versus being wildcards). You can use the DBMS default separator or append a ESCAPE clause you set your own separator.

The default separator varies between different DBMS but the ESCAPE clause works the same way in MySQL and SQL Server (or even in Oracle).

-----

I admit I was sceptical about the whole SQL Server feature but I'm actually using HeidiSQL with SQL Server 2005 for a project this week so I might report some issues if I find them.
Code modification/commit b359c9d from ansgar.becker, 12 years ago, revision 8.0.0.4404
MSSQL: Escape joker chars in conjunction with an "ESCAPE" appendix after the LIKE clause. See http://www.heidisql.com/forum.php?t=12747 .
ansgar's profile image ansgar posted 12 years ago Permalink
What I only find really cumbersome in MSSQL is that the ESCAPE clause does not have a default value. So, when you don't apply the ESCAPE clause, the server assumes nothing is escaped. And then of course the duplicated single quote is an exception to that logic. That's indeed something which could be more simple for MSSQL users.

However, nailed in r4404.

Please login to leave a reply, or register at first.