I have multiple null values in a table including different rows and columns, how I can replace them with one query like using 'all" or *, wherever the Null values in the whole table?
Asked
Active
Viewed 715 times
0
-
show us your query,which you have tried – PowerStar Feb 06 '17 at 09:15
-
1Possible duplicate of [Update columns with Null values](http://stackoverflow.com/questions/3923721/update-columns-with-null-values) – Kasnady Feb 06 '17 at 09:16
-
2Your answer would be here. please check http://stackoverflow.com/questions/19056502/replace-empty-cells-with-null-values-in-large-number-of-columns – Sonali Feb 06 '17 at 09:19
-
1Possible duplicate of [Replace empty cells with NULL values in large number of columns](http://stackoverflow.com/questions/19056502/replace-empty-cells-with-null-values-in-large-number-of-columns) – iDevlop Feb 06 '17 at 09:54
1 Answers
0
Check if column value is null,if yes update with blank values like below code
Update TableName
SET TableName.Column=''
WHERE TableName.Column IS NULL
For Multiple Columns
UPDATE TableName
SET col1 = COALESCE(col1,''),
col2 = COALESCE(col2,''),
col3 = ...
Coln = COALESCE(coln,'')

vinay koul
- 348
- 1
- 9
-
Thanks for reply, I tried what you suggested, but it showing error "Incorrect syntax near the keyword 'column'. My table name is GRN_M so i wrote query as update grn_m set grn_m.Column=' ' where grn_m.Column IS Null – Rahat Ali Feb 06 '17 at 11:25
-
@RahatAli Actually grn_m.Column is your column name for which you want to replace Null values with Blank.Please specify the column names there. – vinay koul Feb 06 '17 at 11:57
-
I understood, as there are so many columns with Null value, I just want to do them in one go, do not want to SET giving every column name, also mentioning name after Where. So is there any way to do it in one go, such as All or * ? – Rahat Ali Feb 06 '17 at 12:04
-
@RahatAli i have updated the above code for multiple column updation.please try with that – vinay koul Feb 06 '17 at 12:13