Error: while inserting data from staging table to target table
Conversion failed when converting date and/or time from character string.
Track: Find the records in which the issue exits
Resolution: Solution to fix the data type issue
query to find which records has the issue:
select *
from
(Select top 100 Serial_Number, Name, Admission_Date,
CASE WHEN TRY_CONVERT(datetime, Admission_Date) IS NULL
THEN 'Cast failed'
ELSE 'Cast succeeded'
END AS Result
from student_staging) a
where Result = 'Cast failed';
Solution: how to fix the data type issue
insert into student
select serial_number, name,
CASE WHEN Admission_Date = ''
THEN NULL
ELSE
(CASE WHEN TRY_CONVERT(datetime, Admission_Date) IS NULL
THEN NULL
ELSE cast ( Admission_Date as datetime)
END )
END AS Admission_Date
from student_staging
In questa pagina del sito puoi guardare il video online SQL Issue: Data Type Conversion(String to DateTime) while Data Loading della durata di ore minuti seconda in buona qualità , che l'utente ha caricato TheSantanuGhosh 01 gennaio 1970, condividi il link con amici e conoscenti, su youtube questo video è già stato visto 355 volte e gli è piaciuto 4 spettatori. Buona visione!