Today in writing a refund of the SQL encountered a problem, directly resulting in the previous record of all operations log, emptied, fortunately, I have to look at the data habits, the following code
1UPDATEtradeuser2 SET 3 Userscore=@UserScore 4 Remark=ISNULL (Remark,')+ ' +@UserName +' manually cancel payment, return points '5 WHERE UserId=@UserID
After the execution of this SQL, the comments are emptied directly, the solution can not find the reason. In fact, the reason is very simple, the incoming @username is null, resulting in a string and null evaluates to NULL, this knowledge point is actually known, but the use of the time is ignored, can be changed to the following
UPDATETradeuserSETUserscore=@UserScoreRemark=ISNULL(Remark,"')+' '+ISNULL(@UserName,"')+'Cancel payment manually and refund points'--This is a custom problem of writing code, with IsNull () judging the incoming parameters . WHEREUserid=@UserID
This kind of problem can be avoided, this is a programmer thinking logic is rigorous, work attitude is correct, oneself to develop the things responsible for themselves. Have doubts to ask more, or out of the problem more embarrassing
02 Development is more validation conditions, as far as possible to avoid empty field values to appear, to minimize the execution of code, do not need to implement the situation should be avoided.
The article speaks the technical point is not many, most are the cumbersome narration, the BO main expression ability is not very strong, cannot concise narrative question, please understanding.
Null small problem in SQL, Big bug