sql - How to preserve datatype following a SELECT INTO? -
i have table t1
date/time fields. i've combined several queries on table union query, , made new table t2
using select on union follows:
select * t2 (select * query1_t1 union select * query2_t1)
the problem query1_t1
substitutes blank string constant of date fields, results in t2 having text fields instead of date/time fields. illustrate:
query1_t1: select myudf(sometextfield),"" newdatefield t1 query2_t1: select anotherudf(sometextfield),olddatefield t1
where olddatefield
date/time.
is there way can structure select into, or change query1_t1
, i'll still same results query newdatefield
end date/time?
you can create table separately adding data it. first, define fields appropriate data types. use insert (columns) select * from
populate it.
updated:
or can hybrid approach. first select into
no rows @ all:
select * t2 query2_t1 1=0
this create of structure. can go , manually adjust data types didn't come through properly.
with structure adjusted, can safely:
insert t2 select * query1_t1 union select * query2_t1
Comments
Post a Comment