Q:

Concat 2 varchars in SQL

I am trying to produce a varchar(20) which is 4 character year + 2 character month. I would like to then use this as a parameter in my stored procedure. Im unable to concatenate 2 varchars together to produce this, any ideas?
SELECT 
    GETDATE() AS CurrentDateTime,
    CONVERT(VARCHAR(20), YEAR(GETDATE())) AS CurrentYear,
    CONVERT(VARCHAR(20), MONTH(GETDATE())) AS CurrentMonth,
    CurrentYear + CurrentMonth AS YearMonth

A:

The simplest approach would be to use this:
SELECT Format(GetDate(), 'yyyyMM') as YearMonth

The function Format() was introduced with Sql Server 2012.

A:

why not simply
SELECT GETDATE() AS CurrentDateTime
 , Convert(VARCHAR(20),YEAR(GETDATE())) AS CurrentYear
 , Convert(VARCHAR(20),MONTH(GETDATE())) AS CurrentMonth
 , Convert(varchar(6), GETDATE(), 112) AS YearMonth

A:

Like this one?
SELECT GETDATE() AS CurrentDateTime
 , Convert(VARCHAR(20),YEAR(GETDATE())) AS CurrentYear
 , Convert(VARCHAR(20),MONTH(GETDATE())) AS CurrentMonth
 , Convert(VARCHAR(20),YEAR(GETDATE())) + Convert(VARCHAR(20),MONTH(GETDATE())) AS YearMonth

Also you can
Year(GetDate()) * 100 + Month(GateDate()) AS YearMonth

or use construction which offered by users below
Convert(varchar(6), GETDATE(), 112) AS YearMonth

