How can I replace/change/delete characters in a SQL Server column?

A. SQL has a reasonably full set of string manipulation tools - all doc'd in the BOL. Some are detailed below.

  • RTRIM/LTRIM - for leading/trailing spaces
  • SUBSTR - standard substring
  • RIGHT
  • CHARINDEX/PATINDEX - find a particular char/pattern
  • STUFF - replace text at given offset(s)
  • REPLACE - SQL 7.0 only. Replaces chars anywhere in a column

Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish