I have to do an insert into a single column/row from a source of multiple values. I'm using the stuff case and I'm so close, but I'm missing one of the expected returns, so I'm not sure what I need to do to make sure I get the results I'm looking for.
HERE is my statement:
SELECT STUFF((SELECT CASE WHEN TotalAmount <=0 THEN 'C' ELSE 'D' END FROM Charges WHERE ChargeNumber=123 FOR XML Path('')), 1,1,'')
The results are D D D
But, I actually have four rows, so I should see D D D D
How can I make sure that I don't delete my first return, if that's what it is doing. WHen I try 0,1 it fails.
Any advice is greatly appreciated, thank you! (Running in SQL Server 2012)