SQL union between NULL and VARCHAR error
===

I have two views with identical columns. One of the columns on the first view is generated 'on the fly' and set as NULL and the same column on the other view has values stored as varchar. I have a stored proc that looks like this:


    ALTER PROCEDURE [dbo].[mi_GetLearners]  
    (@centrename nvarchar(200))  
    AS  
    
    SELECT [centrename]  
          ,[Name]  
          ,[Username] --generated on the fly as NULL
    FROM  [DB1].[dbo].[vw_Learners]  
    WHERE [centrename] = @centrename  
      
    UNION  
      
    SELECT [centrename]  
          ,[Name]   
          ,[Username] --values stored as varchar   
    FROM  [Linked_Server].[DB2].[dbo].[vw_Learners]  
    WHERE [centrename] = @centrename 




DB1 is on SQL Server 2008 R2
DB2 is on SQL server 2005

When I run the stored proc I get the following error:

Msg 245, Level 16, State 1, Line 1
Conversion failed when converting the varchar value 'someusername' to data type int. 

Why is it trying to convert the value to int datatype as the other column is set as NULL? If I instead change the second column from NULL to ' ' the stored proc works fine... I'm really baffled as to why a union between a varchar column and NULL column generated in a select statement would throw such an error... any ideas?
