User475983607 posted
If UniqueId is an integer then your code tries to place a VARCHAR() in an INT column.
Coalesce(convert(varchar(20), UniqueId), convert(varchar(20),[Grand Total]))
The 'Grand Total' looks suspicious too. Unfortunately, you did not share all the relevant code so we can only guess.