title: SQL query works, but SP as a whole does not
body: <p>When I execute the FIRST and SECOND QUERYs through SQL Server Management Studio 2005 they work correctly and modify the correct data. However, when I try to execute the entire SP, I get no errors, but only FIRST actually modifies the data it is supposed to and SECOND does NOT.
  I studied <a href="https://stackoverflow.com/questions/13349545/mysql-query-runs-but-it-doesnt-work-in-sp">THIS Stackoverflow article</a> and think maybe there is confusion in my query too, but I'm not sure how to fix it as im not simply declaring a variable</p>
  
  <p>NOTES: </p>
  
  <p>*The only difference between this and code that worked completely fine is the use of the LEFT commands in FIRST and SECOND. </p>
  
  <p>*While the FIRST query executes in &lt;1, the Second query takes a little over a minute. I'm not sure if this may cause the problem.</p>
  
  <p>*When I execute the entire SP it executes in &lt;1 which shows it is skipping SECOND, but I have no idea why.</p>
  
  <p>*No errors are returned</p>
  
  <pre><code>USE [abc]
  GO
  SET ANSI_NULLS ON
  GO
  SET QUOTED_IDENTIFIER ON
  GO
  -- =============================================
  -- Author:      &lt;Author,,Name&gt;
  -- Create date: &lt;Create Date,,&gt;
  -- Description: &lt;Description,,&gt;
  -- =============================================
  ALTER PROCEDURE [dbo].[bca]
      -- Add the parameters for the stored procedure here
  
  AS
  BEGIN
      -- SET NOCOUNT ON added to prevent extra result sets from
      -- interfering with SELECT statements.
  
  
  ------------------------FIRST------------------------
  UPDATE p
  SET DATAREVISIONTYPE = 'Transfer'
  FROM cba as p
  WHERE DATAREVISIONTYPE  = 'Delete' AND
  (SELECT COUNT([OriginalUserId]) FROM cba WHERE DataRevisionType = 'Add' AND FirstName = p.FirstName 
  AND LastName = p.LastName AND EmployeeEmailAddress = p.EmployeeEmailAddress AND EmployeeBirthdate = LEFT(p.EmployeeBirthdate, 4))&gt; 0
  
  ------------------------SECOND-----------------------
  UPDATE O
  SET DATAREVISIONTYPE = 'Modify'
  FROM cba as O
  WHERE DATAREVISIONTYPE = 'Add' AND
  (SELECT COUNT([OriginalUserId]) FROM cba WHERE DataRevisionType = 'Transfer' AND FirstName = O.FirstName 
  AND LastName = O.LastName AND EmployeeEmailAddress = O.EmployeeEmailAddress AND LEFT(EmployeeBirthdate, 4) = O.EmployeeBirthdate)&gt; 0
  
  END
  </code></pre>
  
  <p>EDIT: Original code without the LEFT commands</p>
  
  <pre><code>USE [abc]
  GO
  /****** Object:  StoredProcedure [dbo].[bca]    Script Date: 07/02/2013 10:14:20 ******/
  SET ANSI_NULLS ON
  GO
  SET QUOTED_IDENTIFIER ON
  GO
  -- =============================================
  -- Author:      &lt;Author,,Name&gt;
  -- Create date: &lt;Create Date,,&gt;
  -- Description: &lt;Description,,&gt;
  -- =============================================
  ALTER PROCEDURE [dbo].[bca]
      -- Add the parameters for the stored procedure here
  
  AS
  BEGIN
      -- SET NOCOUNT ON added to prevent extra result sets from
      -- interfering with SELECT statements.
  
  UPDATE p
  SET DATAREVISIONTYPE = 'Transfer'
  FROM cba as p
  WHERE DATAREVISIONTYPE  = 'Delete' AND
  (SELECT COUNT([OriginalUserId]) FROM cba WHERE DataRevisionType = 'Add' AND FirstName = p.FirstName 
  AND LastName = p.LastName AND EmployeeEmailAddress = p.EmployeeEmailAddress AND EmployeeBirthdate = p.EmployeeBirthdate)&gt; 0
  
  UPDATE O
  SET DATAREVISIONTYPE = 'Modify'
  FROM cba as O
  WHERE DATAREVISIONTYPE = 'Add' AND
  (SELECT COUNT([OriginalUserId]) FROM cba WHERE DataRevisionType = 'Transfer' AND FirstName = O.FirstName 
  AND LastName = O.LastName AND EmployeeEmailAddress = O.EmployeeEmailAddress AND EmployeeBirthdate = O.EmployeeBirthdate)&gt; 0
  
  
  END
  </code></pre>