I am doing STUFF in my query which is concatenating the blank data too and data looks like below. Sometimes there is space+comma and sometimes only comma in the beginning which i need to remove.
Could you help with same. I tried case statement but that makes the query really bigger.
It sounds like you are using code that you don't fully understand.
STUFF does not concatenate text. It replaces a segment of a string in the specified position with another string. I'm assuming that you are using the STUFF/XML combo, in which case it is the XML that is concatenating the text.
Here is the syntax:
STUFF(<string expression>, <start position>, <length>,<replacement text>). An example would be
STUFF(',345,678', 1, 1, '') which would replace the section starting in position 1 and length 1, i.e.,
, and replacing it with an empty string
J. Drew Allen
Business Intelligence Analyst