All,
When I query an External Table which has a datetime column why is it giving me an error even though I was able to enter data into it successfully? This table is pointing to Azure Blob Storage.
Msg 7320, Level 16, State 110, Line 28Cannot execute the query "Remote Query" against OLE DB provider "SQLNCLI11" for linked server "(null)". Query aborted-- the maximum reject threshold (0 rows) was reached while reading from an external source: 1 rows rejected out of total 1 rows processed.
(/claim/QID639_20200107_154411_0.txt)Column ordinal: 2, Expected data type: DATETIME, Offending value: 2010-01-06 00:00:00.000 (Column Conversion Error), Error: Conversion failed when converting the NVARCHAR value '2010-01-06 00:00:00.000' to data type DATETIME.
CREATE EXTERNAL TABLE dbo.wasbs_Claim ( ID int, Claim VARCHAR(128), Claimdate datetime ) WITH ( LOCATION = '/claim/', -- see below comment DATA_SOURCE = csvsource, FILE_FORMAT = csvformat ) GO insert into dbo.wasbs_Claim(ID,Claim,Claimdate) Values (1,'Automobile','01/06/2010') -- Will fail GO select * from dbo.wasbs_Claim
The below T-SQL query goes through though:
DECLARE @stringdate nvarchar(100) SET @stringdate = '2020-01-06 00:00:00.000' DECLARE @datetime datetime SET @datetime = @stringdate PRINT @datetime PRINT @stringdate