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
SQL SERVER - Order By Numeric Values Formatted as String

SQL SERVER – Order By Numeric Values Formatted as String

October 23, 2012
Pinal Dave
SQL Tips and Tricks
SQL Server, SQL String

A column holds alphanumeric values that start with a number, and ORDER BY sorts them as text. Here is how to sort the rows by the Numeric part instead.

Read More
SQL SERVER - Find First Non-Numeric Character from String

SQL SERVER – Find First Non-Numeric Character from String

October 14, 2012
Pinal Dave
SQL Tips and Tricks
SQL Function, SQL Scripts, SQL String

No built-in function finds the first non-numeric character in a string, so I use PATINDEX. Here is a quick script with sample data you can try.

Read More
Hands squaring a neat stack of plain envelopes beside a messy pile, a red rubber band around the tidy stack

Cleaning Address Data in T-SQL: Trimming, Casing and Standardizing

October 12, 2012
Pinal Dave
SQL Tips and Tricks
SQL Function, SQL Scripts, SQL Server, SQL String

Start cleaning address data with preserved originals, normalized spaces, careful casing, street-word mappings, and postal-code review flags.

Read More
A tall boot beside a small open shoebox that holds only a small red paper star instead of the boot.

Why CAST to a Short VARCHAR Returns a Star Instead of an Error

September 20, 2012
Pinal Dave
SQL Tips and Tricks
SQL Datatype, SQL Function, SQL Server, SQL String

Understand why a short VARCHAR returns a star for an integer, compare Unicode errors and string truncation, and size conversions safely.

Read More
Gouache painting of a tray of mixed buttons on a sewing table, with a few matching vermilion buttons set apart in a small dish.

REGEXP_COUNT in SQL Server 2025: Counting Pattern Matches in Text

August 25, 2012
Pinal Dave
SQL Tips and Tricks
SQL Function, SQL Scripts, SQL String

REGEXP_COUNT counts how many times a pattern matches inside a text value, a job that used to need LEN and REPLACE tricks. This post tests it on SQL Server 2025: start position, flags, NULL and empty text, a data quality check, and where the old trick still fits.

Read More
A harmonica exposes separate chambers from one end, with a small vermilion accent on its casing

PARSENAME for Dotted Values: Build Numbers and Object Names

July 29, 2012
Pinal Dave
SQL Tips and Tricks
SQL Function, SQL Instance, SQL Order By, SQL String

Why does revision 12 sort before 7? Because the parts are text. Here is how PARSENAME fixes it, and where it trips you up.

Read More
A pepper mill holds peppercorns above its mechanism with an unsuitable pebble caught before grinding

Second-Order SQL Injection: When Stored Data Becomes Code

May 30, 2012
Pinal Dave
SQL Tips and Tricks
Dynamic SQL, SQL Server Security, SQL String, SQL Variable

A safe insert does not make the saved value safe forever. Here is how stored text turns into code later, and the plain fix.

Read More
Previous 1 … 9 10 11 12 13 14 15 … 22 Next
  • Books
  • Testimonials
  • Privacy Policy

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