title: CONCAT in SQL Server 2014
body: <p>I have a problem when I want to use <code>CONCAT</code> inside my stored procedure. I press execute and get this error message:</p>
  
  <blockquote>
    <p>Mens 195, Nivel 15, Estado 10, Procedimiento upd_agregar, Línea 96'<br>
    CONCAT' is not a recognized built-in function name.</p>
  </blockquote>
  
  <p>This is my table:</p>
  
  <pre><code>create table sucursales
  (
      idSucursal  nvarchar(5) primary key,
      idEmpresa   int not null,
      sucursal    nvarchar(25) not null,
      direccion   nvarchar(100) not null,
      telefono    nvarchar(25),
      email       nvarchar(25) not null,
      constraint fk_suc_emp foreign key(idEmpresa) 
                  references empresas(idEmpresa)
  )
  </code></pre>
  
  <p>This is my query:  </p>
  
  <pre><code>create procedure upd_agregar
      (@idEmpresa int, 
       @sucursal nvarchar(25),
       @direccion nvarchar(100),
       @telefono nvarchar (25),
       @email nvarchar(25))
  as
      declare @longitud int, @codEmpresa nvarchar(2),@codSucursal nvarchar (2)
  
      --Generar codigo de empresa
      IF len(@idEmpresa) &lt; 2
          SET @codEmpresa = CONCAT ('0',@idEmpresa)
      ELSE
          SET @codEmpresa = @idEmpresa
  GO
  </code></pre>
  
  <p>and then when I want to make a select like this, I receive an error that I must declare a scalar variable @codSucursal:</p>
  
  <pre><code>SELECT @codSucursal = isnull(max(cast(substring (idSucursal,4,2)AS int)),0) + 1 FROM sucursales 
  WHERE idEmpresa = @idEmpresa
  </code></pre>