Thursday, 10 July 2014

CONCAT in SQL Server 2012


CONCAT is one of the new string function which introduced in SQL server 2012.

CONCAT:

CONCAT function takes  ‘n’ number of arguments and concatenates them into single string.

Syntax:

CONCAT ( value1, value2………ValueN)

Properties of CONCAT Function:

  1. It takes minimum two values else it will throws an error
  2.  All Values are implicitly converted to String type
  3.  If all values are NULL then it returns an empty string of Varchar(1)  

Example:



SELECT CONCAT ( 'Today Is',07, '/', 10,' Of July' ) AS Result;

And output is:




SELECT CONCAT ( 'Today Is', datepart(dd,getdate()),'/',datepart(mm,getdate()) ) AS Result;


No comments:

Post a Comment