• UMG Developer (3/21/2011)


    Interesting question, thanks, and a good reason you should always specify the data type for hardcoded items in the first set of values or in the first query when using UNION.

    I'm not sure this is true. It looks to me Data Type Precendence determines the data type not the order in the UNION or VALUES clause. Consider the following.

    create table #test(c1 varchar(10), c2 varchar(10));

    insert into #test

    select '','I' union all

    select 3,'J';

    select * from #test;

    Which returns

    c1 c2

    0 I

    3 J

    Data Type Prescendance http://msdn.microsoft.com/en-us/library/ms190309.aspx