Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial


Robin Burgess
Robin Burgess
4,110 Points

Concatenation vs. Addition in MS SQL?


I am currently taking my SQL baby steps in hopes that I can apply the knowledge at work. We use Microsoft SQL at work, and the Teacher's Notes in "Adding Text Columns Together" in the Reporting course mentions that + is the concatenation operator in MS SQL.

Though I haven't bumped into this yet, I am curious-- how does one differentiate this from addition? To use the example presented by one of the lessons, if I wanted to add a processing fee (say, 10.80) to the base cost (say, 110.45) and alias it to a "total" column, how can I ensure that I end up with "121.25" and not "110.4510.80"?

1 Answer

Text strings are surrounded by quotes:

10.80 + 110.45 = 121.25

"10.80" + "110.45" = "10.80110.45"

10.80 + "110.45" = Error. You can't add a number to a string.

If you were using variables or field names instead of constants, it would depend on how they were defined; numeric or text.