create table #variant (data varbinary(8), data_type char(1))
insert #variant values(-291, 'i')
insert #variant values(1, 'i')
insert #variant values(convert(varbinary(8), 'czx'), 'c')
insert #variant values(convert(varbinary(8), 35.25), 'f')
insert #variant values(convert(varbinary(8), 35.3333), 'f')
select case when data_type = 'i' then convert(int, data) end as int_data,
case when data_type = 'c' then convert(varchar, data) end as char_data,
case when data_type = 'f' then convert(decimal(6, 4), data) end as decimal_data,
data_type
from #variant
This page was last updated on May 01, 2006 04:28 PM.