Reputation: 95
I have this task where I need to assign a value if the value is null.
if its not null then I want to keep the value that is already there.. (this is what is stumping me) I know its got to be easy..
Thanks, Al
Upvotes: 1
Views: 1414
Reputation: 13386
Coalesce() is what you should use, it's part of the ansi-99 standard as well.
Update [Table] Set
Col1 = coalesce(Col1, @Col1Val)
,Col2 = coalesce(Col2, @Col2Val)
Where ...
Upvotes: 1