title: ALTER LOGIN gives Incorrect Syntax near 'PASSWORD' error
body: <p>I have created a stored procedure that can be called to change the password of a SQL Server 2008 Login.  When I run the procedure, I get the error:</p>
  
  <blockquote>
    <p>Incorrect syntax near 'PASSWORD'.</p>
  </blockquote>
  
  <p>Here is my stored procedure:</p>
  
  <pre><code>ALTER PROCEDURE [dbo].[proc_update_user]
  (
      @arg1       varchar(255) = null,
      @arg2       varchar(255) = null
  ) AS
  BEGIN
  
  DECLARE @SQLString NVARCHAR(500);
  
  SET @SQLString = 'ALTER LOGIN ' + @arg1 + ' WITH PASSWORD = ''' + @arg2 + '''';
  EXEC sp_executesql @SQLString
  
  END
  </code></pre>
  
  <p>I am calling the procedure with <code>exec proc_update_user 'Billy' , 'newPassword';</code>
  If I run the following query in SQL Server Management Studio, the user is updated without issues:</p>
  
  <pre><code>ALTER LOGIN Billy WITH PASSWORD = 'newPassword';
  </code></pre>
  
  <p>Any idea why my procedure is giving the error?</p>
  
  <p><strong>Edit:</strong>
  This is the code I use to call the stored procedure in C++.  I added this to compare to one of the answers given.  I don't think my problem lies in my C++ code because executing <code>exec proc_update_user 'Billy' , 'newPassword'</code> in management studio is giving me the error.  The stored procedure obviously doesn't work in my application either.</p>
  
  <pre><code>strcpy(szProcName,"{?=call dbo.proc_update_user(?,?)}");
  rc=SQLPrepare(sqlc.g_hstmt,(SQLCHAR*)szProcName,(SQLINTEGER)strlen(szProcName));
              rc=SQLBindParameter(sqlc.g_hstmt,1,SQL_PARAM_OUTPUT, SQL_C_SLONG, SQL_INTEGER,0,0,
                  (SQLPOINTER) &amp;test_val,0,&amp;m_cbRetValue);
  rc=SQLBindParameter(sqlc.g_hstmt,2,SQL_PARAM_INPUT,SQL_C_CHAR, SQL_VARCHAR,sizeof(Login_Name),0,
                  Login_Name,sizeof(Login_Name),&amp;Login_Name_Len);
  rc=SQLBindParameter(sqlc.g_hstmt,3,SQL_PARAM_INPUT,SQL_C_CHAR, SQL_VARCHAR,sizeof(Password),0,
                  Password,sizeof(Password),&amp;Password_Len);
  rc = SQLExecute(sqlc.g_hstmt);
  </code></pre>