February 5, 2014

SQL Server - Concatenation

To concatenate two or more character or binary strings, + sign string operator should be used.

Syntax:

expression + expression

For Example:

SELECT 'Avesh' + ' Dhakal'

Result: Avesh Dhakal

When you need to concat two integer than first of all you need to conver/cast them into string and then concat them.

For Example:

SELECT CAST(1 AS VARCHAR(10)) + ' ' + CAST(2 AS VARCHAR(10))

Result: 1 2

No comments: