Reading decimal mark comma with an external table
2
votes
1
answer
1057
views
SQL Server 2016, SQL Server Management Studio (SSMS). Creating external tables with Transact-SQL and Polybase. How can we read decimals with a decimal mark, comma instead of dot?
When using
float
and decimal
, it fails and throws an error. When using money
data type it succeeds, but misreads decimals and integers are returned instead.
Revised the file format standard clause, no option to configure such a thing. Collation already set for my region.
Sample data:
-none
2017;4;2017;601PPP;183,63;0
2017;4;2017;601PPP;183,63;0
2017;4;2017;601PPP;183,63;1.000,55
2017;4;2017;601PPP;183,63;2,5
2017;4;2017;601PPP;183,63;7,5
2017;4;2017;601PPP;405,28;17,5
Example of a create table that would fail to read the sample data:
CREATE EXTERNAL TABLE [dbo].[STG_Table] (
field1 smallint NULL
,field2 tinyint NULL
,field3 smallint NULL
,fieldn_2 varchar(10) NULL
,fieldn_1 money NULL
,fieldn float NULL
)
WITH (LOCATION='/STG_Table/',
DATA_SOURCE = AzureDataSource,
FILE_FORMAT = FileFormat
);
Query used to read data:
SET @dynamicSQL = N'SELECT * INTO ##' + @someTable + ' FROM STG_' + @someTable
EXEC sp_executesql @dynamicSQL
Specifying fields implies more cases to be added (working inside a procedure) and it can be avoided by configuring such a thing. I found more simple configuring this, than adding more code. No configuration found in database configuration.
Asked by SNR
(139 rep)
Jan 13, 2018, 03:26 PM
Last activity: Aug 23, 2021, 10:47 AM
Last activity: Aug 23, 2021, 10:47 AM