Я хочу сохранить дату из excel в SQL
я Тринг, чтобы сохранить файл данных Excel в таблицу SQL...данных Excel также содержит дату
получаю ошибку: '
conversion fail date/or time from character string
'Что я уже пробовал:
мой формат даты excel-это
10/11/17
или 10/11/2017
в sql тип столбца datetime
мой фрагмент sp -
MERGE INTO EmployeeDetails AS ED USING @tvp_EmployeeDetails AS tED ON ED.EmpCode = tED.EmpCode AND isnull(ED.EmpCode,'') <> '' and ED.EmpCode in (select EmpCode from dbo.UserDetails) WHEN MATCHED THEN UPDATE SET ED.EmpCode = tED.EmpCode, ED.DOJ = tED.DOJ, ED.PermantAddress = tED.PermantAddress, ED.PrimaryMissionID = tED.PrimaryMissionID, ED.SecondaryMissionID = tED.SecondaryMissionID, ED.AltitudeId = tED.AltitudeId, ED.Extension = tED.Extension, ED.ApplicationId_V1 = tED.ApplicationId_V1, ED.ApplicationId_V2 = tED.ApplicationId_V2, ED.ApplicationId_Others = tED.ApplicationId_Others, ED.TrainingStartDate = tED.TrainingStartDate, ED.TrainingEndDate = tED.TrainingEndDate, ED.CertificationDate = tED.CertificationDate, ED.CertificationAttempt = tED.CertificationAttempt, ED.OnBoardDate = tED.OnBoardDate, ED.SeparationDate = case tED.SeparationDate when '' then null else tED.SeparationDate end, ED.SeparationReason = tED.SeparationReason, ED.DisciplinaryAction = tED.DisciplinaryAction, ED.EmpImage = tED.EmpImage, ED.UpdatedBy =@UserID, ED.UpdatedOn = GETDATE() WHEN NOT MATCHED THEN INSERT ([EmpCode],[DOJ] ,[PermantAddress] ,[PrimaryMissionID] ,[SecondaryMissionID] ,[AltitudeId] ,[Extension],[ApplicationId_V1] ,[ApplicationId_V2] ,[ApplicationId_Others] ,[TrainingStartDate],[TrainingEndDate],[CertificationDate] ,[CertificationAttempt] ,[OnBoardDate] ,[SeparationDate],[SeparationReason],[DisciplinaryAction],[EmpImage] ,[CreatedBy],[CreatedOn]) values (tED.EmpCode, case when isdate(tED.DOJ)=1 then tED.DOJ else null end , tED.PermantAddress,tED.PrimaryMissionID,tED.SecondaryMissionID,tED.AltitudeId,tED.Extension,tED.ApplicationId_V1, tED.ApplicationId_V2, tED.ApplicationId_Others, case when isdate(tED.TrainingStartDate)=1 then tED.TrainingStartDate else null end, case when isdate(tED.TrainingEndDate)=1 then tED.TrainingEndDate else null end, case when isdate(tED.CertificationDate)=1 then tED.CertificationDate else null end,tED.CertificationAttempt, case when isdate(tED.OnBoardDate)=1 then tED.OnBoardDate else null end, case when isdate(tED.SeparationDate)=1 then tED.SeparationDate else null end ,tED.SeparationReason,tED.DisciplinaryAction,tED.EmpImage, @UserID, GETDATE()) ;
Suvendu Shekhar Giri
Попробуйте преобразовать содержимое этого столбца в "гггг-ММ-ДД" и посмотреть, поможет ли это :)