title: Collation Conflict error working on local sql not on server hosting database
body: <p>I have t-sql which is working fine on the local sql server if I run the same t-sql on the remote sql server hosting the database ginving the error </p>
  
  <p>I tried a lot of changes but nothing works for me finally I decide to write on Stack Exchange.</p>
  
  <p>I cretaed my local database with the script from the server so I hope no chance if their is change in any datatypes as my query is giving me correct result. </p>
  
  <p>Here is my t-sql</p>
  
  <pre><code>IF OBJECT_ID('tempdb..#TempAppliedData') IS NOT NULL  
    BEGIN  
          DROP TABLE #TempAppliedData  
    END  
  
  Create Table #TempAppliedData(
  --RecordNo [int],
  IdNo1 [nvarchar](50) COLLATE DATABASE_DEFAULT,
  --Name [nvarchar](50),
  AYear2011 [char](3) COLLATE DATABASE_DEFAULT,
  AYear2012 [char](3) COLLATE DATABASE_DEFAULT,
  AYear20121 [char](3) COLLATE DATABASE_DEFAULT, 
  AYear2013 [char](3) COLLATE DATABASE_DEFAULT,
  AYear20131 [char](3) COLLATE DATABASE_DEFAULT
  );
  
  
  insert into #TempAppliedData (IdNo1) select distinct  IdNo from AppliedData
  
  
  update #TempAppliedData 
  set 
  AYear2011=(select CASE WHEN COUNT(A.Year2011)=0 then 'No' else 'YES' end FROM AppliedData A WHERE Year2011='Yes' and IdNo1=IdNo) ;
  
  
  update #TempAppliedData 
  set 
  AYear2012=(select CASE WHEN COUNT(A.Year2012)=0 then 'No' else 'YES' end FROM AppliedData A WHERE ApplnYear &lt;=20131 AND Year2012='Yes' and IdNo1=IdNo)
  
  
  update #TempAppliedData 
  set 
  AYear20121=(Select CASE WHEN COUNT(A.Year20121)=0 then 'No' else 'YES' end FROM AppliedData A WHERE ApplnYear &lt;=20131 AND Year20121='Yes' and IdNo1=IdNo)
  
  
  
  update #TempAppliedData 
  set 
  AYear2013=(Select CASE WHEN COUNT(A.Year2013)=0 then 'No' else 'YES' end FROM AppliedData A WHERE ApplnYear &lt;=20131  AND Year2013='Yes' and IdNo1=IdNo)
  
  
  update #TempAppliedData 
  set 
  AYear20131=(Select CASE WHEN COUNT(A.Year20131)=0 then 'No' else 'YES' end FROM AppliedData A WHERE ApplnYear &lt;=20131  AND Year20131='Yes' and IdNo1=IdNo)
  
  
  
  
  Select * from #TempAppliedData;
  
  --select distinct IdNo from AppliedData
  </code></pre>
  
  <p>Its producing error is as below:</p>
  
  <pre><code>Msg 468, Level 16, State 9, Line 28
  Cannot resolve the collation conflict between "SQL_Latin1_General_CP1_CS_AS" and "SQL_Latin1_General_CP1_CI_AS" in the equal to operation.
  Msg 468, Level 16, State 9, Line 40
  Cannot resolve the collation conflict between "SQL_Latin1_General_CP1_CS_AS" and "SQL_Latin1_General_CP1_CI_AS" in the equal to operation.
  Msg 468, Level 16, State 9, Line 53
  Cannot resolve the collation conflict between "SQL_Latin1_General_CP1_CS_AS" and "SQL_Latin1_General_CP1_CI_AS" in the equal to operation.
  Msg 468, Level 16, State 9, Line 66
  Cannot resolve the collation conflict between "SQL_Latin1_General_CP1_CS_AS" and "SQL_Latin1_General_CP1_CI_AS" in the equal to operation.
  Msg 468, Level 16, State 9, Line 79
  Cannot resolve the collation conflict between "SQL_Latin1_General_CP1_CS_AS" and "SQL_Latin1_General_CP1_CI_AS" in the equal to operation.
  </code></pre>