data type for null in union query

  • Thread starter Thread starter Phil Hellmuth
  • Start date Start date
P

Phil Hellmuth

I'm attempting to run a union query like this:

SELECT Null as FieldA
FROM Table1

UNION

SELECT NumericField
FROM Table2

Unfortunately, FieldA is returned as a text field, not numeric. Can I add
something to define the proper data type? Flipping the order of the select
statements is not an option. I suppose I could hack and add a select
statement on top like 'Select 0' with a condition that will never occur, but
I'd prefer something more elegant.

Thanks in advance.
 
The workaround you suggest is probably the simplest:
SELECT IIf(False, 1, Null) AS FieldA ...
 
Back
Top