-2

I have a table that contains a list of titles.

And due to a problem something went wrong and the values now are like

title1[null]
title2[null][null]
title[null]3[null]

And the likes, I need to replace all [NULL] to NOTHING. so everything will be okay again. THank you.

Please advice.

PS.

[null] is not an actual string but the value NULL itself like the hex 00.

nambla
  • 71
  • 2
  • 11

2 Answers2

2

Stackoverflow already has an existing answer:

REPLACE(myString, char(0), '')

Source: Replace null character in a string in sql

This might help too: What is the Null Character literal in TSQL?

Community
  • 1
  • 1
Michael Buen
  • 38,643
  • 9
  • 94
  • 118
1

This is for MS SQL

 UPDATE table_name SET column_name = REPLACE(column_name, '[null]', '')

NEW ANSWER AFTER UPDATE ABOUT '[NULL]' BEING THE NULL CHARACTER, NOT TEXT:

 UPDATE table_name SET column_name = REPLACE(column_name, char(0), '')
XN16
  • 5,679
  • 15
  • 48
  • 72
  • @nambla What it the problem with it? Works for me. – XN16 Aug 12 '12 at 08:18
  • @nambla Ah I get the issue now... I thought you meant the text '[null]' was in the string, not the actual null character! Answer updated! – XN16 Aug 12 '12 at 09:05