From your description, it seems that this is all a single paragraph with soft line breaks. To check (Word 2010, but should work in 2013 as well), turn on Show all, which is the paragraph mark button on the home tab (I don't remember which group). A soft line break will show up as a bent arrow pointing down and left, while a paragraph break will show up as a paragraph mark.
If it is all one paragraph, what you're experiencing is Word's designed behavior. Word assumes any direct character formatting applied to more than half of a paragraph (the blue color, in this case) is the "normal" character format of the paragraph. When you apply the style, it overwrites the normal format with whatever is in the style. The red and black are treated as exceptions, so they're left alone.
A couple of possible solutions:
Paste the code into Word, copy everything except the paragraph mark at the end (easiest if Show all is turned on), and paste into a blank paragraph that already has the desired style applied. This should keep the direct formatting (although reapplying the style will change the blue to black).
Paste directly from the Server Management Studio into a paragraph that already has the desired paragraph style. I suspect this one won't work (you're probably pasting in a whole paragraph, with its own paragraph formatting), but it's worth a try.
Create and apply character styles for the colors before applying the paragraph style. This is a little more work to set up, but applying a paragraph style shouldn't overwrite any formatting applied through character styles.
Just live with it and reapply the colors manually. This is definitely not an ideal solution, but with Word the simplest option is often to let the program do whatever it wants and then clean things up when it isn't looking.
If this isn't all one paragraph, then I don't know what's causing it. Word is weird sometimes.