O'Reilly logo

Microsoft® SQL Server 2012 Unleashed by Alex T. Silverstein, Chris Gallelli, Paul T. Bertucci, Ray Rankins

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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:

PS>$last_name="Doe"PS>$first_name="John"PS>$full_name=$last_name+", "+$first_namePS>$full_nameDoe, JohnPS>

In this example, two variables containing simple strings are defined, and they are simply concatenated together with a comma character between them 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 AdventureWorks2012 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required