0
中的數據類型時轉換失敗我收到錯誤「錯誤:將varchar值'10.8'轉換爲數據類型時出錯」。錯誤:在將varchar值'10.8'轉換爲
我正在Azure數據倉庫中寫入此查詢。 什麼可能是錯的,我沒有做任何轉換爲Int。
select
cast(
case
when [total_amount] is null then 0
when [total_amount] = '' then 0
else [total_amount]
end
as decimal(10,4)
)
FROM [dbo].[ABC]
這個查詢是一個外部表查詢其也報告錯誤在查詢執行計劃步驟2,從外部表[NYCTaxiData]拒絕 6行:
Location: '/2016/yellow_tripdata_2016-07.csv' Column ordinal: 17, Expected data type: VARCHAR(50) collate SQL_Latin1_General_CP1_CI_AS, Offending value: VendorID,tpep_pickup_datetime,tpep_dropoff_datetime,passenger_count,trip_distance,RatecodeID,store_and_fwd_flag,PULocationID,DOLocationID,payment_type,fare_amount,extra,mta_tax,tip_amount,tolls_amount,improvement_surcharge,total_amount (Tokenization failed), Error: Not enough columns in this line.
Location: '/2016/yellow_tripdata_2016-10.csv' Column ordinal: 17, Expected data type: VARCHAR(50) collate SQL_Latin1_General_CP1_CI_AS, Offending value: VendorID,tpep_pickup_datetime,tpep_dropoff_datetime,passenger_count,trip_distance,RatecodeID,store_and_fwd_flag,PULocationID,DOLocationID,payment_type,fare_amount,extra,mta_tax,tip_amount,tolls_amount,improvement_surcharge,total_amount (Tokenization failed), Error: Not enough columns in this line.
Location: '/2016/yellow_tripdata_2016-11.csv' Column ordinal: 17, Expected data type: VARCHAR(50) collate SQL_Latin1_General_CP1_CI_AS, Offending value: VendorID,tpep_pickup_datetime,tpep_dropoff_datetime,passenger_count,trip_distance,RatecodeID,store_and_fwd_flag,PULocationID,DOLocationID,payment_type,fare_amount,extra,mta_tax,tip_amount,tolls_amount,improvement_surcharge,total_amount (Tokenization failed), Error: Not enough columns in this line.
Location: '/2016/yellow_tripdata_2016-09.csv' Column ordinal: 17, Expected data type: VARCHAR(50) collate SQL_Latin1_General_CP1_CI_AS, Offending value: VendorID,tpep_pickup_datetime,tpep_dropoff_datetime,passenger_count,trip_distance,RatecodeID,store_and_fwd_flag,PULocationID,DOLocationID,payment_type,fare_amount,extra,mta_tax,tip_amount,tolls_amount,improvement_surcharge,total_amount (Tokenization failed), Error: Not enough columns in this line.
Location: '/2016/yellow_tripdata_2016-08.csv' Column ordinal: 17, Expected data type: VARCHAR(50) collate SQL_Latin1_General_CP1_CI_AS, Offending value: VendorID,tpep_pickup_datetime,tpep_dropoff_datetime,passenger_count,trip_distance,RatecodeID,store_and_fwd_flag,PULocationID,DOLocationID,payment_type,fare_amount,extra,mta_tax,tip_amount,tolls_amount,improvement_surcharge,total_amount (Tokenization failed), Error: Not enough columns in this line.
Location: '/2016/yellow_tripdata_2016-12.csv' Column ordinal: 17, Expected data type: VARCHAR(50) collate SQL_Latin1_General_CP1_CI_AS, Offending value: VendorID,tpep_pickup_datetime,tpep_dropoff_datetime,passenger_count,trip_distance,RatecodeID,store_and_fwd_flag,PULocationID,DOLocationID,payment_type,fare_amount,extra,mta_tax,tip_amount,tolls_amount,improvement_surcharge,total_amount (Tokenization failed), Error: Not enough columns in this line.
什麼** datatype **是你的'total_amount'列? –
它是varchar(50)NULL –