Hi Team,
As part of server migration we came across strange behaviour in SQL 2012 and SQL 2016 versions. please help to understand why SQL converting into different data types in different SQL versions.
In SQL Server 2016:
SELECT * into test
FROM OPENQUERY(LS_SOURCE,'SELECT POLICY_ID FROM POLICY where POLICY_ID = 37468')
sp_help test
Column_name Type Computed Length Prec Scale Nullable TrimTrailingBlanks FixedLenNullInSource Collation
POLICY_ID float no 8 53 NULL no (n/a) (n/a) NULL
SQL Server 2012:
SELECT * into test
FROM OPENQUERY(LS_SOURCE,'SELECT POLICY_ID FROM POLICY where POLICY_ID = 37468')
sp_help test
Column_name Type Computed Length Prec Scale Nullable TrimTrailingBlanks FixedLenNullInSource Collation
POLICY_ID nvarchar no 768 no (n/a) (n/a) SQL_Latin1_General_CP1_CI_AS
The data type for policy_id column in source server table POLICY is Number NOT NULL. Could you please help to understand why
Number colummn converted to nvarchar (768) in SQL 2012 server and float in SQL 2016 in SQL Server table (test)
why collation is SQL_Latin1_General_CP1_CI_AS in SQL 2012 server and NULL in SQL 2016 for newly created table column (test.policy_id)