0

Dear Stackoverflow members,

I have a field in a database

BH90ABBB01010215529101

How do i amend it to replace the 9th to 16th characters with X

BH90ABBBXXXXXXXX29101
Gordon Linoff
  • 1,242,037
  • 58
  • 646
  • 786
ahmed
  • 45
  • 7
  • Read about the STUFF() function here: https://learn.microsoft.com/en-us/sql/t-sql/functions/stuff-transact-sql?f1url=https%3A%2F%2Fmsdn.microsoft.com%2Fquery%2Fdev15.query%3FappId%3DDev15IDEF1%26l%3DEN-US%26k%3Dk(Stuff_TSQL);k(sql13.swb.tsqlresults.f1);k(sql13.swb.tsqlquery.f1);k(MiscellaneousFilesProject);k(DevLang-TSQL)%26rd%3Dtrue&view=sql-server-ver15 – StoneGiant Jun 23 '20 at 13:45
  • Does this answer your question? [How to replace nth character in sql server](https://stackoverflow.com/questions/28674797/how-to-replace-nth-character-in-sql-server) – Ruud Helderman Jun 23 '20 at 13:46
  • 2
    Your SQL dialect is not clear. `ms-query` (used in MS Office applications like Excel) is distinctly different from `sql-server` (MS's flagship relational database). Please tag or describe appropriately. – Parfait Jun 23 '20 at 13:53

1 Answers1

0

What you need is the STUFF function.

Like this:

SELECT STUFF('BH90ABBB01010215529101', 9, 9, 'XXXXXXXX')
michi-p
  • 211
  • 2
  • 10