-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.

2
  • 1
    Your schema and values aren't understandable, plz elaborate more, or use SQL fiddle or some other tool to convey your problem. Commented Aug 12, 2012 at 7:40
  • SQL server ? Use REPLACE function Commented Aug 12, 2012 at 7:42

2 Answers 2

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?

Sign up to request clarification or add additional context in comments.

Comments

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), '')

2 Comments

@nambla What it the problem with it? Works for me.
@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!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.