Joining Variables and Strings

The concept of objects was already introduced briefly. When you are dealing with simple strings, you can easily concatenate them together using the plus (+) sign to create a new string:

image

In this example, two variables containing simple strings are defined, and they are simply concatenated together to create a third variable, which is then displayed to the console.

Note

This kind of concatenation works when both variables are strings. An error may be returned if the variable is of another data type.

An example is provided later with the AdventureWorks2008R2 database where string variables from two different columns ...

Get Microsoft® SQL Server 2008 R2 Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.