Monday, February 24, 2014

sql server concatenation

TSQL provides 2 ways to concatenate data, the + sign and the new CONCAT() function. This tip will cover the differences in the two, so you can achieve the expected behavior in your code.

The way most us are used to concatenating data together is using the + sign. The problem we run into using this method is it expects the different items being concatenated together to be of the same data type. You have to perform an explicit conversion if they are not the same data type. The following example is trying to concatenate a INT and a String together, you can see SQL cannot handle the different data types.

Refer:

http://www.mssqltips.com/sqlservertip/3014/concatenation-of-different-sql-server-data-types/?utm_source=dailynewsletter&utm_medium=email&utm_content=headline&utm_campaign=20140224

No comments:

Post a Comment