Concatenating strings | SQL Server Performance Forums

SQL Server Performance Forum – Threads Archive

Concatenating strings

I am sure this is a simple one, but for some reason my brain isn’t working today… I am trying to concatenate several fields in a select statement, but for some reason SQL is truncating the resulting string at 256 characters. I have tried using CONVERT to force the result into a VARCHAR(8000) but it is just not working. What can I do?

Dont forget query analyser only shows the first 256 chars of any column by default. You can change this in options. Could this be the problem ? If tno can you post your sql statement
quote:Originally posted by Chappy Dont forget query analyser only shows the first 256 chars of any column by default. You can change this in options. Could this be the problem ?

Doh! That is most likely it – I completely forgot about that. I’ll check when I get back to the office tomorrow morning.

Don’t forget to check for NULL in fields that allow that. <br />It’s enough to have one field with a NULL to end up with NULL. <img src=’/community/emoticons/emotion-1.gif’ alt=’:)‘ /><br /><br />Bambola.
<blockquote id="quote"><font size="1" face="Verdana, Arial, Helvetica" id="quote">quote:<hr height="1" noshade id="quote"><i>Originally posted by bambola</i><br /><br />Don’t forget to check for NULL in fields that allow that. <br />It’s enough to have one field with a NULL to end up with NULL. <img src=’/community/emoticons/emotion-1.gif’ alt=’:)‘ /><br /><br />Bambola.<br /><hr height="1" noshade id="quote"></blockquote id="quote"></font id="quote"><br /><br />I have that issue licked – SET CONCAT_NULL_YIELDS_NULL OFF is your friend! [<img src=’/community/emoticons/emotion-1.gif’ alt=’:)‘ />]<br />
quote:Originally posted by Chappy Dont forget query analyser only shows the first 256 chars of any column by default. You can change this in options. Could this be the problem ?

That was it. I should have realised earlier. (I recently got a new machine and hadn’t changed all of the options I usually set.) Thanks for your help.

]]>