This month's discount Comprehensive Database Performance Health Check · Testimonials
SQLAuthority with Pinal Dave
Home
  • Consulting
    • Health Check
  • Free Videos
  • All Articles
    • AI
    • SQL Performance
    • SQL Tips and Tricks
    • Interview Questions and Answers
    • SQL Puzzle
    • SQL Video
    • SQLAuthority News
    • Personal
  • Books
  • Consulting
One brass key blank fits a precise profile jig while a similar blank with a different ridge rests outside

LIKE Character Ranges: [a-f], [^0-9] and Collation Traps

August 9, 2011
Pinal Dave
SQL Tips and Tricks
SQL Collation, SQL NULL, SQL String, Unicode

A bracket range sounds simple until the collation decides what sits between a and f. Test it once so a bad code never reaches your table.

Read More
Table of eight shop names with the character code of each apostrophe and whether LIKE found it. Three straight marks, code 39, were found. Two curly marks, code 8217, were not found

Finding Apostrophes in SQL Server Text: Straight and Curly

August 3, 2011
Pinal Dave
SQL Tips and Tricks
SQL Scripts, SQL Search, SQL String, Unicode

Finding apostrophes in SQL Server text takes one trick and one trap. The trick is doubling the quote inside a LIKE pattern. The trap is that text can hold a curly apostrophe, and the usual search skips it. This post tests both on a table of eight shop names.

Read More
Three LIKE symbols shown as cards: percent sign, underscore and open bracket, each with the number of rows that contain it next to the number of rows LIKE found, and a row of plain symbols whose counts matched

Special Characters in a LIKE Pattern: Which Ones Are Wildcards

August 2, 2011
Pinal Dave
SQL Tips and Tricks
SQL Operator, SQL Scripts, SQL Search, SQL String

Special characters in a LIKE pattern can match the wrong rows, because three symbols mean more than themselves. This post tests every common symbol on one small table. It shows how to search for a percent sign, an underscore and a bracket, and why a space in the pattern counts.

Read More
Four LIKE wildcards with a real example each: percent matches Baker and Brooks for B percent, underscore finds Baker, Patel and Taylor for underscore a percent, [A-K] returns five names, and [^A-K] returns nine

Wildcard Basics in SQL Server: How LIKE Patterns Work

August 1, 2011
Pinal Dave
SQL Tips and Tricks
SQL Operator, SQL Scripts, SQL Search, SQL String

Wildcard basics for SQL Server: how LIKE works with %, _, sets and ranges, shown on one small table of last names. It also covers the mistakes with equal signs and sets, case and accents in ranges, and matching a wildcard literally. Every result comes from SQL Server 2025.

Read More
A cut rose branch with thorns, pruning shears and a clay pot on a greenhouse workbench.

REGEXP_REPLACE Text Cleanup: Replacing Tags Is Not Parsing HTML

June 3, 2011
Pinal Dave
SQL Tips and Tricks
SQL Function, SQL Scripts, SQL Server, SQL String

REGEXP_REPLACE can remove controlled tag-like text, but that is not the same as parsing HTML. Test quoted brackets, surviving script text and word boundaries before deciding whether the replacement fits the input.

Read More
Two identical glasses of water, one with a red drop sinking in it

Rows That Look Identical but Are Not: Finding Hidden Characters

April 1, 2011
Pinal Dave
SQL Tips and Tricks
SQL Collation, SQL Server, SQL String, Unicode

Expose hidden characters with DATALENGTH and UNICODE, clean known whitespace safely, and add a constraint to prevent recurrence.

Read More
Gouache painting: a cream garment bag hangs from a wooden wardrobe rail, unzipped halfway so a slate-blue jacket shows clearly inside

FOR XML PATH: Decode Escaped Text Through TYPE

January 24, 2011
Pinal Dave
SQL Tips and Tricks
SQL Datatype, SQL Scripts, SQL String

FOR XML PATH escapes reserved characters. Use TYPE and scalar extraction to recover text instead of manually replacing entity spellings.

Read More
Previous 1 … 12 13 14 15 16 17 18 … 23 Next
  • Books
  • Testimonials
  • Privacy Policy

© 2006 – 2026 All rights reserved. pinal @ SQLAuthority.com