0

I have NULL values in my table.

SELECT [Id] ,[Mark] ,[Series] ,[Models] ,[Power] FROM [ExcelAnalysis].[dbo].[Dict] 

Here the screen http://imgur.com/a/kAOYA

so i try do so

update tablename set fieldname = REPLACE ( fieldname , string_pattern , string_replacement ) update [dbo].[Dict] set [Mark] = REPLACE ( [Mark] , 'NULL' , '' ) 

but after executing the query, NULL values i see again

How correct delete it?

2
  • 1
    You don't seem to know what null is. And why would you want to replace it with an empty string? Commented Jun 15, 2017 at 11:41
  • NULL is not a value. It represents the absence of a value. Commented Jun 15, 2017 at 11:45

2 Answers 2

1

Compare with NULL (null value, please, notice absence of the apostrophs), not 'NULL' (string NULL)

 update [dbo].[Dict] set [Mark] = '' where [Mark] is null 
Sign up to request clarification or add additional context in comments.

5 Comments

Thanks you) i understood ,the null is not string)
so , Dmitry, how do this replace for all field at once select * :)
@D.Joe: Sorry, I don't follow you? If you want "if field is null substitute it with '' " construction, try Coalesce(field, ''). Coalesce returns 1st not null value
i mean replace NULL in all table at once))
@D.Joe: the query in the answer replaces all null values in the [Mark] fields for the entire [dbo].[Dict] table
1

For NULL use COALESCE() or a WHERE clause:

update [dbo].[Dict] set [Mark] = '' where [Mark] is null; 

NULL is not a string value.

1 Comment

Probably would be better to not just replace NULL with an emtpy string but explain what NULL is.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.