ARTICLE

String Concatenation and Scope Resolution Operator in SQL Server 2008 R2

Posted by Dhananjay Kumar Articles | SQL Server 2012 March 03, 2011
Here you will learn String Concatenation and Scope Resolution Operator in SQL Server 2008 R2.
Reader Level:

Target Audience: Beginners

SQL Server 2008 R2 comes with String Concatenation Operator.

String Concatenation operator is denoted by symbol plus '+'.

string1.gif

Output we will get,

string2.gif

String concatenation operator can concatenate string with real time data of any type also.

string3.gif

In above query , firstName and lastName column is being concatenated using string concatenation operator of SQL Server 2008 R2. In above query we are also concatenating HireDate . Since HireDate is of type DateTime , we need to convert that first before concatenating.

string4.gif

SQL Server 2008 R2 comes with Scope Resolution Operator.

Scope Resolution operator is denoted by symbol '::'

It is used to access static members of compound data type.

string5.gif

In above query hierarchyId is a compound data type. And we are accessing static function GetRoot() of this type.

Output

string6.gif

Login to add your contents and source code to this article
post comment
     

Does that mean the string concatenation operator '+' is a new feature of SQL Server 2008 R2? Was this not possible in earlier versions? I am sure I have done this many times even in previous versions. Also you mentioned scope resolution operator. There are no further details and the information is almost similar to what MSDN page shows @ http://msdn.microsoft.com/en-us/library/dd206995.aspx. And verify your facts about this too. This operator is available in SQL 2008 (yes non R2 version) too.

Posted by Vijay Gill Mar 03, 2011
COMMENT USING
PREMIUM SPONSORS
DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and add new content to existing PDF documents from within your applications.
SPONSORED BY
  • PDF reports have never been easier to create. With our included WYSIWYG Designer, you can layout your reports, set up your data source and let DynamicPDF ReportWriter do the rest.