pksutha (3/23/2011)
Hi Gopi,select * into TestTable from
(
select CAST(1 as smallint) as C1, CAST(6 as smallint) as C2
union
select CAST(2 as tinyint),CAST(6 as int)
union
select CAST(3 as bigint),CAST(6 as smallint)
union
select CAST(4 as int),CAST(6 as tinyint)
) T
Note: Practically i want to see the difference... will u give example for that..
Hi pksutha,
try this query to see the resulting data type:
SELECT RowID
,Col
,SQL_VARIANT_PROPERTY(Col,'BaseType') BaseType
,SQL_VARIANT_PROPERTY(Col,'Precision') Precision
,SQL_VARIANT_PROPERTY(Col,'Scale') Scale
,SQL_VARIANT_PROPERTY(Col,'TotalBytes') TotalBytes
,SQL_VARIANT_PROPERTY(Col,'Collation') Collation
,SQL_VARIANT_PROPERTY(Col,'MaxLength') MaxLength
FROM (
SELECT 1 AS RowID, CAST(1 AS int) Col
UNION ALL SELECT 2 AS RowID, CAST('2' AS char) Col
)SubQ
And play a little with the datatypes & order of data types in the CASTs to see what the resulting data type will be.
Best Regards,
Chris Büttner