Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
sqlobsessed
Starting Member
8 Posts |
Posted - 2012-06-03 : 00:19:00
|
| I figured out this statement below to append 'test' into a field that already contains data that I do not want to override. Problem:If the field does not data and is NULL, this statement does not add 'test' into the field. How should I modify my update statement?update orderdetailset comments= comments +' '+ 'test' where orderid=1028 |
|
|
mani_12345
Starting Member
35 Posts |
Posted - 2012-06-03 : 00:25:17
|
| yes off course u get null becz anything concatenatd with null alwys give u a null for this u can use replace(<column name >,'null','value u want to enter ' ) i thnk u vl get appropriate answer .. |
 |
|
|
sqlobsessed
Starting Member
8 Posts |
Posted - 2012-06-03 : 00:37:00
|
| Thanks, that makes sense. I am making a general statement that appends all fields, NULL or not.Where exactly do I place your suggestion where it will run properly?:update orderdetailset comments= comments +' '+ 'test' replace(<comments>,'null','test ' ) where orderid=1028 |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-06-03 : 00:43:44
|
| [code]update orderdetailset comments= coalesce(comments +' ','')+ 'test' where orderid=1028ode[/code]------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
sqlobsessed
Starting Member
8 Posts |
Posted - 2012-06-03 : 00:48:59
|
| Thank you both so much! It works for both :o) Alot of people are going to be very happy with this in my company! |
 |
|
|
mani_12345
Starting Member
35 Posts |
Posted - 2012-06-03 : 00:59:42
|
| nice :) |
 |
|
|
|
|
|